<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Instruction separation</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="language.basic-syntax.phpmode.html">Escaping from HTML</a></div> <div class="next" style="text-align: right; float: right;"><a href="language.basic-syntax.comments.html">Comments</a></div> <div class="up"><a href="language.basic-syntax.html">Basic syntax</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="language.basic-syntax.instruction-separation" class="sect1"> <h2 class="title">Instruction separation</h2> <p class="para"> As in C or Perl, 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; you do not need to have a semicolon terminating the last line of a PHP block. The closing tag for the block will include the immediately trailing newline if one is present. <div class="informalexample"> <div class="example-contents"> <div class="phpcode"><code><span style="color: #000000"> <span style="color: #0000BB"><?php<br /> </span><span style="color: #007700">echo </span><span style="color: #DD0000">'This is a test'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?><br /></span><br /><span style="color: #0000BB"><?php </span><span style="color: #007700">echo </span><span style="color: #DD0000">'This is a test' </span><span style="color: #0000BB">?><br /></span><br /><span style="color: #0000BB"><?php </span><span style="color: #007700">echo </span><span style="color: #DD0000">'We omitted the last closing tag'</span><span style="color: #007700">;</span> </span> </code></div> </div> </div> <blockquote class="note"><p><strong class="note">Note</strong>: <p class="para"> 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 <span class="function"><a href="function.include.html" class="function">include</a></span> or <span class="function"><a href="function.require.html" class="function">require</a></span>, so unwanted whitespace will not occur at the end of files, and you will still be able to add headers to the response later. It is also handy if you use output buffering, and would not like to see added unwanted whitespace at the end of the parts generated by the included files. </p> </p></blockquote> </p> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="language.basic-syntax.phpmode.html">Escaping from HTML</a></div> <div class="next" style="text-align: right; float: right;"><a href="language.basic-syntax.comments.html">Comments</a></div> <div class="up"><a href="language.basic-syntax.html">Basic syntax</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>