PHP Function Reference

PHP __halt_compiler() Function



The PHP __halt_compiler() function halts the execution of the compiler. This can be useful to embed data in PHP scripts, like the installation files.

Byte position of the data start can be determined by the __COMPILER_HALT_OFFSET__ constant which is defined only if there is a __halt_compiler() presented in the file.

Syntax

__halt_compiler()

Parameters

No parameter is required.

Return Value

No value is returned.

Example: __halt_compiler() example

The example below shows the usage __halt_compiler() function.

<?php
//opening this file
$fp = fopen(__FILE__, 'r');

//seeking 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.)

Note: __halt_compiler() can only be used from the outermost scope.

❮ PHP Miscellaneous Reference