(PHP 5 >= 5.1.0, PHP 7, PHP 8)
__halt_compiler — 中斷編譯器的執行
中斷編譯器的執行。常用于在PHP腳本內嵌入數據,類(lèi)似于安裝文件。
可以通過(guò)常量 __COMPILER_HALT_OFFSET__
獲取數據開(kāi)始字節所在的位置,且該常量?jì)H被定義于使用了__halt_compiler的文件。
沒(méi)有返回值。
示例 #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() 僅能夠在最外層使用。