What is the โ€œrightโ€ way to start and close a PHP statement?

Is there any difference or related risk discovery with the following PHP options?

<? echo "hello world!"; ?>

<?php echo "hello world!"; ?>

<?="hello world!"?>

In addition, you must close all scripts with ?>

+5
source share
3 answers

, short_open_tag. , , , <?php, , , , , . , , <?xml. , , - short_open_tag; , , ( . )

, - , , , . Zend PHP.

, , , , , PHP. , , , ) <?= , ) -, . " " .

+15

, . , PHP, , , , , .

, , .

+6

. , . , , , . , - - . , . - , ,

, PHP, , , ?

The only real consideration (imho) is XML processing instructions, which can be a problem if you output XHTML, although I have never seen a reason to do this instead of strict or transitional HTML.

+2
source

All Articles