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

shahidkarimi's avatar

PHP 7.0 Laravel 5.5 Error: Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE)

I have PHP 7.0 both with apache and CLI but having the follwoing error:

`Parse error: syntax error, unexpected '?', expecting variable (T_VARIABLE)'

This error is raising when sending email using gmail smtp

0 likes
5 replies
elvijs's avatar

I'd start by adding the following bit to your routes/web.php file:

Route::get('phpinfo', function () {
    return phpinfo();
});

Visit your www.yoursite.com/phpinfo and double check if there are no references to older PHP version.

bobbybouwmann's avatar

Are you sure your application is using PHP7.0? Also you could have made a typo somewhere and that will trigger this error as well!

shahidkarimi's avatar
shahidkarimi
OP
Best Answer
Level 1

Yes phpinfo() also gives 7.0. Its a bug. It has been fixed when upgraded to php 7.1

1 like

Please or to participate in this conversation.