syntax error, unexpected '?'
sinchanroy opened this issue · 2 comments
$ php -S localhost:8080
PHP 5.4.16 Development Server started at Mon May 10 13:23:27 2021
Listening on http://localhost:8080
Document root is /home/si.roy/simple-php-website
Press Ctrl-C to quit.
[Mon May 10 13:23:32 2021] PHP Parse error: syntax error, unexpected '?' in /home/si.roy/simple-php-website/includes/functions.php on line 36
[Mon May 10 13:23:32 2021] ::1:46572 [200]: / - syntax error, unexpected '?' in /home/si.roy/simple-php-website/includes/functions.php on line 36
From Another host :
[si.roy@jenkins ~]$ curl http://localhost:8080
Parse error: syntax error, unexpected '?' in /home/si.roy/simple-php-website/includes/functions.php on line 36
[si.roy@jenkins ~]$
PHP Version :
$ php -v
PHP 5.4.16 (cli) (built: Oct 29 2019 09:56:22)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
You need to edit code like below.
[includes/functions.php: line 36]
// $query_string = str_replace('page=', '', $_SERVER['QUERY_STRING'] ?? '');
$query_string = str_replace('page=', '', isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '');
Double question mark(??
) in php is available after php 7.
Can you assign me this?