W3TC and PHP 7

Parameter 1 to W3_Plugin_TotalCache

HabschnedIn case you haven’t heard of, or are not using it, W3 Total Cache then i suggest to take a closer look at it. If you are concerned about the speed of your WordPress Blog then this plugin is what you are looking for. It’s probably the best caching plugin out there for WordPress and, at the same time, very easy to configure.


With PHP7 being available now i’ve seen a number of support threads reporting an error after the PHP version was upgraded from 5.x to 7.x. The exact error message is

and it displays at the bottom of the page. Now, when checking line 3297 in /wp-includes/functions.php you won’t see any reason as to why that line generates an error…in my functions.php file line 3297 actually holds some comments. Here is what’s in my /wp-includes/functions.php file.

So, looking at line 3297 isn’t really helpfu, is it? Took a while to figure out what’s wrong. Instead of looking at /wp-includes/functions.php locate the TotalCache.php file which normally is located in wp-content/plugins/w3-total-cache/lib/W3/Plugin/TotalCache.php. Open the file in a text editor (Notepad will do) and look for line 512 which should be

Now, to fix that

error you simply have to remove the ampersand from line 512 in wp-content/plugins/w3-total-cache/lib/W3/Plugin/TotalCache.php. Here is a “before” and “after”.

Before code change:

After code change:

Save the changes, clear all caches just to be sure that no cached versions of anything are being served and when now loading your WordPress blog the error should be gone.

Be the first to comment

Leave a Reply

Your email address will not be published.