PHP Instruction Termination

Each statement made in PHP needs a method of indicating the end of the statement so that each instruction can be carried out without mix-up. The semicolon “;” is used for this purpose.

$variable = "Why can you never swindle a snake?";
echo $variable;

The block of code above contains two separate instructions inside the opening and closing php tags. Each statement, or instruction, is terminated with a semicolon. Many errors are caused by forgetting to terminate a statement.

The closing php tag can be used as instruction termination, making the following block of code an option as long as code is not added between the second statement and the closing tag:

$variable = "Because it's impossible to pull its leg!";
echo $variable


This site uses Akismet to reduce spam. Learn how your comment data is processed.