Search code examples
syntax-errormampphp-7php-5.6

why does this code cause error on PHP 7.0 but not 5.6


I just updated my development server to PHP 7 and I am getting an error that I was not getting on MAMP with PHP 7. Here is the code:

$GLOBALS['PLACEHOLDERS'] = array(
                        "search"=>
                            array(
                                "%PAGE.NAME%", 
                                "%PAGE.TITLE%", 
                                "%PAGE.DESCRIPTION%",
                                "%PAGE.REFERENCE%", 
                                "%PAGE.ADMINTOOLBAR%",
                                "%PAGE.ADMININCLUDES%",
                                "%ROOT%"
                            ),
                        "replace"=>
                            array(
                                "<?= \$_SESSION['PAGE']['name']; ?>",
                                "<?= \$_SESSION['PAGE']['name']; ?>",
                                "<?= \$_SESSION['PAGE']['description']; ?>",
                                "<?= str_replace(array('/', '.php'), array('_', ''), \$_SESSION['PAGE']['reference']); ?>",
                                "<? base_renderAdminToolbar(); ?>",
                                "<? base_renderAdminIncludes(); ?>",
                                "<?= ROOT; ?>"
                            )
                        );

I am getting a

 PHP Parse error:  syntax error, unexpected '$_SESSION' (T_VARIABLE), expecting identifier (T_STRING) in /home/vjukebox/public_html/_engine/config.php on line 124

line 124 is the first "<?= \$_SESSION['PAGE']['name']; ?>", line on my developement server but this code worked find on PHP 7 on MAMP and PHP 5.6 on the developement server.


Solution

  • Enabling short_open_tags in the php.ini resolved the issue.