On the html page I open the php tag, the variables declared in one block of tags are not visible in another. There is no such problem on php 5.6. I have nginx + php-fpm, linux mint

Closed due to the fact that off-topic participants cheops , aleksandr barakin , Streletz , user207618, HamSter 11 Oct '16 at 6:12 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • “Questions asking for help with debugging (“ why does this code not work? ”) Should include the desired behavior, a specific problem or error, and a minimum code for playing it right in the question . Questions without an explicit description of the problem are useless for other visitors. See How to create minimal, self-sufficient and reproducible example . " - cheops, aleksandr barakin, Streletz, Community Spirit, HamSter
If the question can be reformulated according to the rules set out in the certificate , edit it .

  • show clearly .... tobish code .. any errors? turn on error_reporting - Alexey Shimansky
  • <? $ a = 'Ivan'?> Hello <? = $ a> The variable $ a is not declared - hik
  • short tags are not included ...... php.ini -> short_open_tag = On - Alexey Shimansky
  • short_open_tag ... <? php $ a = 'Ivan'?> Hello <? = $ a> works - sepgg
  • <?= since version 5.4 is always enabled and does not depend on short_open_tag ....... so you need to look ini - Alexey Shimansky

1 answer 1

With PHP 5.4.0, the special short <?= Tag is always available, but the usual short tags <? must be enabled with the directive short_open_tag=On

Therefore, the code

 <? $a='Ivan'?> 

NOT executed. That is, the variable $ a is not assigned anything.

And the code

 <?=$a ?> 

already executed, and honestly tells us that the variable is not set

It is also worth noting that the use of short tags <? ?> <? ?> not recommended, because they are far from being allowed everywhere and the code, respectively, loses much of portability.

  • <?=$a> this is not correct so <?=$a ?> - Naumov
  • @Naumov yes, copied from the author, not paying attention. thanks - rjhdby