PHP Parse error: syntax error, unexpected T_FUNCTION during upgrade from OJS 2.4.8 to OJS

I’m trying to upgrade my journal to version OJS

Using the command
$ php tools/upgrade.php upgrade

It shows immediatelly:

PHP Parse error: syntax error, unexpected T_FUNCTION in /home/storage/X/XX/XX/my_journal/public_html/lib/pkp/includes/ on line 251

My PHP Version is 7.0.21

Any idea to help? Hi @ctgraham can you help or let me know who can, please?


The PHP construct in question is here:

This should be supported in PHP 7.0 to my knowledge, but PHP 7.0 itself is past end of life. Are you able to try this under PHP 7.1 or 7.2?

Hi @ctgraham, thanks for reply.

I tried now with PHP Version 7.1.13 (the host doesn’t have 7.2).
The error keeps the same… Any other suggestion?


I did a test in Putty, by typing php -v, see the results:
PHP 5.2.17 with Suhosin-Patch 0.9.7 (cli) (built: Mar 22 2011 17:39:28)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
with the ionCube PHP Loader v4.0.9, Copyright (c) 2002-2011, by ionCube Ltd., and
with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies

My host setup PHP version by using .htacess but the internal version keeps old. Is there any other way to run the command line using the new PHP version?

From the command line, there will be different paths to the different PHP installations. For example, PHP7 could be installed as /usr/local/php-7.1.3/bin/php or similar. Running php might default to /usr/bin/php, but you can execute the PHP 7 executable directly on the command line. Ask your hosting provider for the correct path to PHP7.