PHP Instruction Separation


 

PHP Instruction Separation

In this tutorial we will study about how to separate instruction in PHP. In general we use ; sign to separate the instructions but what are the other ways are present in PHP are discussed in this tutorial.

In this tutorial we will study about how to separate instruction in PHP. In general we use ; sign to separate the instructions but what are the other ways are present in PHP are discussed in this tutorial.

PHP Instruction Separation:

PHP follows the same way to terminate the instructions as C, Perl, or most of the popular languages do. PHP use ' ; ' to terminate any instruction but at the same time it is not necessary to put a semi colon at the last line of the code.

As in the example given below, we can see that none of the line has semicolon, whenever we use closing bracket it automatically indicates the end of the instruction.

(Note: The tags used in the example are not usual tags of PHP, these are called asp like tags, to enable these kind of tags change the value of the asp_tags to "on" , in php.ini file)

Example of PHP Instruction Separation:

<%echo "Hello"%>

<%echo "World"%>

Output:

HelloWorld

Example:

<?php

$var=12;

if($var==12){

?>

<strong>Equal to tweleve</strong>

<?php

}

else{

?>

<strong>Not equal to tweleve</strong>

<?php

}

?>

Output:

Equal to tweleve

 

Ads