__halt_compiler

(PHP 5 >= 5.1.0, PHP 7, PHP 8)

__halt_compiler 中断编译器的执行

说明

__halt_compiler(): void

中断编译器的执行。常用于在 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() 仅能够在最外层作用域使用。

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top