farse Posted October 12, 2020 Share Posted October 12, 2020 In PHP 5, I conventionally opened my pages with <?php but within the pages I often used <? to open a php block, e.g., <?echo $variable; ?>. In PHP 7, I find it is necessary to always use <?php and follow it with a space, e.g., <?php echo $variable; ?> I haven't been able to find any reference to this syntax change so my question: Is this a new requirement of PHP 7? Can it be turned off? Otherwise, I will need to edit all of the sites where my earlier habit was used, which I think I can do but would feel compelled to spend some hours testing afterward. Link to comment Share on other sites More sharing options...
dsonesuk Posted October 12, 2020 Share Posted October 12, 2020 I believe you can set it to accept both. Short tags and long tags. Link to comment Share on other sites More sharing options...
Funce Posted October 13, 2020 Share Posted October 13, 2020 As an alternative with your <? echo $var ?> blocks, you can use <?= $var; ?>. This can be used regardless of the php_short_tags setting, which you can read up on here: https://www.php.net/manual/en/language.basic-syntax.phptags.php Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now