Memory App
Programming
 




Short tags

Short tags have the major drawback of conflicting with XML headers. With normal open tags the result is correct.

<?php
    echo <<<EOF
    <?xml version="1.0" ?>
EOF;
?>
With short php tags the result is incorrect. This displays EOF;

<?
    echo <<<EOF
    <?xml version="1.0" ?>
EOF;
?>
(1/3)

Closing tag

It is good practice to ommit the closing php tag.

<?php // test.php

    $a = 1; 
?>
[newline]
[newline]
Newlines are used as separators between the header of HTTP server response and the actual data.

<?php // index.php

    error_reporting(E_ALL);
    include('test.php');
    header("HTTP/1.0 404 Not Found");
This wil result in a Warning: Cannot modify header information - headers already sent http://stackoverflow.com/questions/3219383/why-do-some-scripts-omit-the-closing-php-tag (2/3)

Code blocks


// block code A
{
    echo 1;
}

// block code B
{
    echo 2;
}


Questions



Top Reference > Programming
0/0 (80)  
Not Logged