Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

marjangvg's avatar

Laravel 5.4 on PHP 5.6.40 Syntax error

Hi,

I have Laravel 5.4 installed on PHP 5.6.4 server, and i can't start the app. Everything works ok locally with the same configuration, but on the server i get this error:

(1/1) FatalErrorException syntax error, unexpected '?', expecting variable (T_VARIABLE)

in PDOConnection.php line 24

Thanks :)

0 likes
3 replies
Cronix's avatar

Are you sure both the web and cli versions of php are the same version (5.6.4)?

marjangvg's avatar

This is the local config:

PHP 5.6.19 PDO drivers: mysql

Server web

PHP 5.6.40 (phpinfo: https://dev.careertools.com.au/phpinfo.php)

CLI version is 7.2

I can't change the server version because there's old php code that would not work on 7. Will changing the cli version fix it ?

jlrdw's avatar

PHP 5.6.19 code will run (should) on php 7.2. I'm on 7.3 and have had no trouble with older code.

The only thing I've had to do is an older framework rename a class from error to something else.

That is unless you have some way out in left field code.

Please or to participate in this conversation.