The "Notice: Only variable references should be returned by reference" error in Moodle is the same PHP compatibility issue that affects several older PHP applications. The code uses a syntax pattern that modern PHP versions flag as incorrect.
Update Moodle to the latest version
Current versions of Moodle have resolved these PHP compatibility issues. Visit moodle.org to download the latest release. If you cannot update immediately, suppress PHP notices via cPanel > Software > MultiPHP INI Editor.
01. Update Moodle
The proper fix is to update Moodle. Before updating:
- Back up your database and files - See How to Back Up Your Website
- Check Moodle's system requirements for the version you are upgrading to (PHP version, database version, etc.)
- Update PHP if needed - See How to Change Your PHP Version
- Follow Moodle's upgrade documentation at moodle.org
02. Temporary Fix: Suppress Notices
PHP notices are informational messages, not errors. Your Moodle installation still functions with these notices appearing. To hide them, create a .user.ini file in your Moodle directory:
error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT
Or use cPanel > Software > MultiPHP INI Editor to change the error reporting level for your domain.
Moodle is a complex application used for education. Running an outdated version poses security risks for both you and your users' data. If you manage student information, updating is especially important for data protection compliance.
Need Help With Moodle?
If you need assistance updating Moodle or resolving PHP errors, open a support ticket.
Open a Support TicketFrequently Asked Questions
What causes the Only variable references notice in Moodle?
It is a PHP compatibility notice. Older Moodle code uses a syntax pattern that newer PHP versions flag. It is a notice, not a fatal error, so Moodle usually still works, but the message can clutter pages or logs.
How do I fix the Moodle reference notice?
Update Moodle to a current version compatible with your PHP version, which removes the outdated syntax. Keeping Moodle current is the recommended fix and also keeps you secure.
Can I hide the notice without updating Moodle?
Yes, as a temporary measure you can suppress PHP notices via error reporting so they do not display, which stops the message from showing. This hides the symptom only; plan to update Moodle for the real fix.
Will this notice break my Moodle site?
Usually not, since it is a notice rather than a fatal error, so the site generally keeps working. It can fill logs and occasionally show on screen. Updating Moodle or suppressing notices clears it.
Quick Recap
- This is a PHP compatibility notice, not a fatal error
- Update Moodle for the proper fix
- Suppress notices temporarily via .user.ini if you cannot update yet
- Back up everything before updating
- Check PHP version requirements for the new Moodle version
PHP script compatibility · Last updated November 2026 · Browse all PHP Scripts articles
