banago / simple-php-website

An introductory example of how to build a simple and minimal website built with PHP.
293 stars 722 forks source link

syntax error, unexpected '?' #56

Open sinchanroy opened 3 years ago

sinchanroy commented 3 years ago

$ 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

Yunsang-Jeong commented 3 years ago

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.

Samkit-shah commented 2 years ago

Can you assign me this?