- PHP requires instructions to be terminated with a semicolon at the end of each statement.
- The closing tag (?>) of a block of PHP code automatically implies a semicolon(;)
- (Ref-Example 2), so you do not need to have a semicolon terminating the last line of a PHP block.
- Example 1:
1
2
3
4
5
6
7
| <?php
echo 'This is a test';
echo 'This is another test';
?>
|
- Example 2:
1
| <?php echo 'This is a test' ?>
|
- Example 3:
1
| <?php echo 'We omitted the last closing tag';
|
- Note: The closing tag of a PHP block at the end of a file is optional and in some cases omitting it is helpful when using include() or require(),
- So unwanted white space will not occur at the end of files, and you will still be able to add headers to the response later.
No comments:
Post a Comment