Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 8886

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!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>PHP tags</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="language.basic-syntax.html">Basic syntax</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="language.basic-syntax.phpmode.html">Escaping from HTML</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.phptags" class="sect1">
   <h2 class="title">PHP tags</h2>
   <p class="para">
    When PHP parses a file, it looks for opening and closing tags,
    which are <em>&lt;?php</em> and <em>?&gt;</em>
    which tell PHP to start and stop interpreting the code between
    them. Parsing in this manner allows PHP to be embedded in all
    sorts of different documents, as everything outside of a pair
    of opening and closing tags is ignored by the PHP parser.
   </p>
   <p class="para">
     PHP also allows for short open tags <em>&lt;?</em> and <em>?&gt;</em>
    (which are discouraged because they are only available if enabled with
    <a href="ini.core.html#ini.short-open-tag" class="link">short_open_tag</a> <var class="filename">php.ini</var> configuration
    file directive, or if PHP was configured with the <strong class="option unknown">--enable-short-tags</strong>

    option.
   </p>
   <p class="para">
    If a file is pure PHP code, it is preferable to omit the PHP closing tag at the
    end of the file.  This prevents accidental whitespace or new lines being added after the PHP
    closing tag, which may cause unwanted effects because PHP will start output
    buffering when there is no intention from the programmer to send any output
    at that point in the script.
    <div class="informalexample">
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"Hello&nbsp;world"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;...&nbsp;more&nbsp;code<br /><br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">"Last&nbsp;statement"</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">//&nbsp;the&nbsp;script&nbsp;ends&nbsp;here&nbsp;with&nbsp;no&nbsp;PHP&nbsp;closing&nbsp;tag</span>
</span>
</code></div>
     </div>

    </div>
   </p>
  </div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="language.basic-syntax.html">Basic syntax</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="language.basic-syntax.phpmode.html">Escaping from HTML</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>