array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'function.halt-compiler.php', 1 => '__halt_compiler', ), 'up' => array ( 0 => 'ref.misc.php', 1 => '杂项 函数', ), 'prev' => array ( 0 => 'function.get-browser.php', 1 => 'get_browser', ), 'next' => array ( 0 => 'function.highlight-file.php', 1 => 'highlight_file', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'zh', 'path' => 'reference/misc/functions/halt-compiler.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 5 >= 5.1.0, PHP 7, PHP 8)
__halt_compiler — 中断编译器的执行
中断编译器的执行。常用于在 PHP 脚本内嵌入数据,类似于安装文件。
可以通过常量 __COMPILER_HALT_OFFSET__
获取数据开始字节所在的位置,且该常量仅被定义于使用了
__halt_compiler() 的文件。
此函数没有参数。
没有返回值。
示例 #1 __halt_compiler() 例子
<?php
// open this file
$fp = fopen(__FILE__, 'r');
// seek file pointer to data
fseek($fp, __COMPILER_HALT_OFFSET__);
// and output it
var_dump(stream_get_contents($fp));
// the end of the script execution
__halt_compiler(); the installation data (eg. tar, gz, PHP, etc.)
注意:
__halt_compiler() 仅能够在最外层作用域使用。