A set of commands is responsible for performing a particular action within the code, regardless of the chosen language. A command line indicates the action and the next, sequentially, will then be read, interpreted and enforced. But for this to happen it is necessary that the code interpreter has a point – character – indicating when actually one line ends and when starts another one.

As in C or Perl, PHP requires instructions to be terminated with a semi-colon at the end of each command. However, the closing tag of a block of PHP code automatically implies a semi-colon, it is not necessary to have a point-colon ending the last line of a PHP block. The closing tag will include a new line just after, if it is present.


echo ‘This is a test’;

<?php echo ‘This is a test’ ?>

<?php echo ‘We omitted the last closing tag’;

The closing tag of a PHP block at the end of a file is optional, and in some cases it is useful to omit it, especially when using an ‘include’ or ‘require’. Thus, unwanted white spaces will not appear at the end of the files and you can still add additional response headers. This type of deployment is also useful if you want to use output buffering, where no one wants to have added a blank space at the end of the parts generated by the included files.

Separation of PHP


Despite the need not to use the PHP closing tag, it is important to pay attention to some points of use:


1)         <?php echo ‘Excluded PHP end tag’;

2)         <?php echo ‘Excluded PHP end tag’;
<p>HTML still visible</p>

In the first example, the code will function normally, as in the following example an error is displayed, whereas a HTML code is written immediately following, without the correct distinction of each type of code. Excluding the need to indicate the end of PHP code only in cases where there are no more code, HTML, for example following.

Another important tip is to use as separators in different lines, as shown in the following example:

echo “First Line”;
echo “Last Line”

The above code would generate an error since the first line possess a finalized command and the line below does not. It is necessary then rewrite this code in the following formats:

echo “First Line”;
echo “Last Line”;


echo “First Line”;
echo “Last Line” ?>

You might also like…

How to implement A2F using Own Development in NodeJS in a Scriptcase application

A2F using Own Development in NodeJS A2F: In a previous article, we talked about Swivel as an extern...

Specialists or generalists, who gets a better advantage by using Scriptcase?

Hey there! Today  we will figure what are the ideal profiles for those who wish to take advantage o...

Disabling autofill and autocomplete Chrome browser in login screens

Hello, here I want to show an alternative to disable the autofill and autocomplete of the chrome bro...

Comment this post

Get new posts, resources, offers and more each week.

We will use the information you provide to update you about our Newsletter and Special Offers. You can unsubscribe any time you want by clinck in a link in the footer of any email you receive from us, or by contacting us at sales@scriptcase.net. Learn more about our Privacy Police.