Source of: /manual/en/function.halt-compiler.php
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.misc.inc";
$setup = array (
'home' =>
array (
0 => 'index.php',
1 => 'PHP Manual',
),
'head' =>
array (
0 => 'UTF-8',
1 => 'en',
),
'this' =>
array (
0 => 'function.halt-compiler.php',
1 => '__halt_compiler',
),
'up' =>
array (
0 => 'ref.misc.php',
1 => 'Misc. Functions',
),
'prev' =>
array (
0 => 'function.get-browser.php',
1 => 'get_browser',
),
'next' =>
array (
0 => 'function.highlight-file.php',
1 => 'highlight_file',
),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);
manual_header();
?>
<div id="function.halt-compiler" class="refentry">
<div class="refnamediv">
<h1 class="refname">__halt_compiler</h1>
<p class="verinfo">(PHP 5 >= 5.1.0)</p><p class="refpurpose"><span class="refname">__halt_compiler</span> — <span class="dc-title">
Halts the compiler execution
</span></p>
</div>
<a name="function.halt-compiler.description"></a><div class="refsect1 description">
<h3 class="title">Description</h3>
<div class="methodsynopsis dc-description">
<span class="type"><span class="type void">void</span></span> <span class="methodname"><b>__halt_compiler</b></span>
( <span class="methodparam">void</span>
)</div>
<p class="para rdfs-comment">
Halts the execution of the compiler. This can be useful to embed data in
PHP scripts, like the installation files.
</p>
<p class="para">
Byte position of the data start can be determined by the
<b><tt class="constant">__COMPILER_HALT_OFFSET__</tt></b> constant which is defined
only if there is a <b>__halt_compiler()</b> presented in the
file.
</p>
</div>
<a name="function.halt-compiler.returnvalues"></a><div class="refsect1 returnvalues">
<h3 class="title">Return Values</h3>
<p class="para">
No value is returned.
</p>
</div>
<a name="function.halt-compiler.examples"></a><div class="refsect1 examples">
<h3 class="title">Examples</h3>
<p class="para">
</p><div class="example">
<p><b>Example #1 A <b>__halt_compiler()</b> example</b></p>
<div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB"><?php<br /><br /></span><span style="color: #FF8000">// open this file<br /></span><span style="color: #0000BB">$fp </span><span style="color: #007700">= </span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">, </span><span style="color: #DD0000">'r'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// seek file pointer to data<br /></span><span style="color: #0000BB">fseek</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">, </span><span style="color: #0000BB">__COMPILER_HALT_OFFSET__</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// and output it<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">stream_get_contents</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">));<br /><br /></span><span style="color: #FF8000">// the end of the script execution<br /></span><span style="color: #007700">__halt_compiler(); </span><span style="color: #0000BB">the installation data </span><span style="color: #007700">(</span><span style="color: #0000BB">eg</span><span style="color: #007700">. </span><span style="color: #0000BB">tar</span><span style="color: #007700">, </span><span style="color: #0000BB">gz</span><span style="color: #007700">, </span><span style="color: #0000BB">PHP</span><span style="color: #007700">, </span><span style="color: #0000BB">etc</span><span style="color: #007700">.)</span>
</span>
</code></div>
</div>
</div><p>
</p>
</div>
<a name="function.halt-compiler.notes"></a><div class="refsect1 notes">
<h3 class="title">Notes</h3>
<blockquote><p><b class="note">Note</b>:
<b>__halt_compiler()</b> can only be used from the outermost
scope.
<br />
</p></blockquote>
</div>
</div><?php manual_footer(); ?>