PHP Fatal Error - Can't use function return value in write context in

Your software
My Mautic version is: 3.1.2
My PHP version is: 7.3.11
My Database type and version is: MySQL v 15.1

Your problem
My problem is:

When I ran a cron job in Webmin to check if they work, I got the following error:

PHP Fatal error: Can’t use function return value in write context in /home/XXXXXXX/public_html/bin/console on line 5

The line 5 is as follows:

#!/usr/bin/env php
<?php

// Fix for hosts that do not have date.timezone set
 **if (empty(ini_get('date.timezone'))) {**
    date_default_timezone_set('UTC');
 }

These errors are showing in the log:

There is no error in the logs

Steps I have tried to fix the problem:

I have re-installed 3.1.2

I then removed 3.1.2 and installed 3.1.0 with the same result

I tried to comment the lines out (5 - 7), but then got the following error message

PHP Parse error: syntax error, unexpected ‘class’ (T_CLASS), expecting identifier (T_STRING) or variable (T_VARIABLE) or ‘{’ or ‘$’ in /home/XXXXXXXXXX/public_html/vendor/hoa/protocol/Wrapper.php on line 582

Hi

Did you ever get an update on this? I have the same issue trying to upgrade to 3.3.2. I have gone into my php settings and changed the blank timezone to one in Europe but still no joy and get the same PHP Fatal error: Can’t use function return value in write context in xxxx

Hi Peter

I should have posted my response earlier. Thanks for the reminder.
I was running Mautic on an unmanaged VPS.
When I accessed Webmin, it indicated that I’m using PHP 7.3.11. In fact Mautic, it also showed PHP 7.3.11 in the config.
However, when I SSH’ed into the VPS and checked the PHP, it showed 5.6.40. So I changed it to PHP 7.3.11 and then it worked.
I hope it helps you too.

1 Like