What does it mean “The closing tag for the block w

2019-05-30 16:46发布

问题:

I am learning to php from php.net but i am confused with the sentence The closing tag for the block will include the immediately trailing newline if one is present. at php.net.

Can anyone tell me what does it says, what is mean by if one is present in this sentence The closing tag for the block will include the immediately trailing newline if one is present. ?

You will see that sentence line at the end of the first paragraph at php.net

回答1:

The closing tag for the block will include the immediately trailing newline if one is present.

Meaning, ?>\n is taken as the block closing delimiter, and both are removed from the final output. I expect this is to remove unnecessary blank lines in code like this:

<ul>
<?php foreach (..) ?>
    <li>..</li>

However, it does make it hard to control output of newlines.

EDIT

Example: if you run

hello

there
<?php echo 'bye'; ?>

<?php echo 'there'; ?> 

It prints

hello

there
bye
there

instead of

hello

there
bye

there

Ignoring the space there is between <?php echo 'bye'; ?> and <?php echo 'there'; ?>

Note: If you want you can use (?> <br>) to output the blank line but this will also output the space between > and <