What is the difference between opening PHP (? php?) and (??)? [duplicate]

0

Friends, I know that the question sounds silly, that I've been studying php for just over a year and this question arose when I used the opening <? ?> and it works in the same way, but I'm sure I do not know why. Can someone more expert tell me?

    
asked by Angel Zambrano 22.09.2017 в 19:19
source

2 answers

3

When PHP analyzes a file, it looks for the opening and closing tags, which are <?php y ?> , and that tell PHP where to start and end the interpretation of the code. This mechanism allows PHP to be embedded in all types of documents, since everything outside the PHP opening and closing tags will be ignored by the analyzer.

PHP also allows the abbreviated opening tag <? (which is inadvisable because it is only available if enabled with the short_open_tag directive from the php.ini configuration file, or if PHP was configured with the --enable-short-tags option %).

Here I leave the full information:

PHP tags

    
answered by 22.09.2017 / 19:22
source
2

They are the same, only one is the long version and the other the short version.

Can be enabled in php.ini using the short_open_tag configuration directive

You can see their explanation in the PHP documentation: short_open_tag and PHP tags

In general it is recommended not to use short tags, because you depend on them being enabled in the configuration (and not all providers allow you to make changes to the configuration), and because having the complete tags, allow you to see clearly when you enter to PHP.

    
answered by 22.09.2017 в 19:28