Joomla ‘Strict Standards: Only variables should be assigned by reference’ Error

While developing a Joomla site I came across the following error which popped up all over the site and screwed everything up:

Strict Standards: Only variables should be assigned by reference in…..

Luckily it was easier to fix than I first thought it would be, you don’t have to edit your Joomla code in any way – you simply have to setup a php.ini file OR if you have a VPS/Dedicated server you can configure PHP from within it’s admin, I use WHM so I can only show you how to edit the PHP install using this.

If you do not have a VPS or dedicated server than you need to create a ‘php.ini’ file or a ‘PHP Config’ file. To do this you will need a code editor like Notepad++.

Create a PHP.ini File

Step One

Open the code editor and paste in the following line:

Step Two

Save the file as ‘php.ini’

Step Three

Upload the file to themes root directory

And that’s it, the errors should be gone and your website should be functioning properly – if this didn’t work for you feel free to leave a comment and I will help you.


Using a PHP Config File

One of the best ways to turn on and off error reporting is by using a PHP config file, and then include this into your theme. This way you can easily turn error reporting back on if needed. Use the following code to set error reporting off:

And then include the file into your themes header by using the following:

Of course, change the file name and location to the correct values.


Configuring the Server

If you have your own server and you use Joomla a lot it’s probably best (I have) to turn off the front end PHP error reporting completely. You can do this from within WHM:

Navigate to PHP Configuration Editor

Click Advanced Mode

Find the ‘display_errors’ setting and turn it off:

WebHost Manager – se1

Save the PHP Configuration and navigate back to your site, the errors should be gone and your site should be working correctly. If not you may need to restart Apache.

If you have any problems getting any of the above to work, let me know in the comments and I will try to help you.