(Php 5> = 5.1.0, Php 7, Php 8)
__HALT_COMPILER - Giảm bớt thực thi trình biên dịch — Halts the compiler execution
Sự mô tả
__halt_compiler (): VOID(): void
Vị trí byte của bắt đầu dữ liệu có thể được xác định bởi hằng số __COMPILER_HALT_OFFSET__
chỉ được xác định nếu có __halt_compiler () được trình bày trong tệp.__COMPILER_HALT_OFFSET__
constant which is defined only if there is a
__halt_compiler() presented in the file.
Thông số
Chức năng này không có tham số.
Trả về giá trị
Không có giá trị được trả về.
Ví dụ
Ví dụ #1 Một ví dụ __halt_compiler ()__halt_compiler() example
<?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.)
Ghi chú
Ghi chú::
__halt_compiler () chỉ có thể được sử dụng từ phạm vi ngoài cùng. can only be used from the outermost scope.
-T- ¶ ¶
8 năm trước
This function can be used in eval() -- it will halt the eval, but not the script eval"() was called in.
Ravenswd tại Gmail Dot Com ¶ ¶
6 năm trước
If "__halt_compiler();" appears in a file which is "include"d or "require"d, then the called-in file will be treated as if it physically cuts off at the "__halt_compiler();". In other words, "__halt_compiler();" only affects the physical file it's in, an outer file that pulls it in will continue to execute.
Ravenswd tại Gmail Dot Com ¶ ¶
6 năm trước
__halt_compiler is also useful for debugging. If you need to temporarily make a change that will introduce an error later on, use __halt_compiler to prevent syntax errors. For example:
<?php
if ( $something ):
print 'something';
endif; // endif placed here for debugging purposes
__halt_compiler();
endif; // original location of endif -- would produce syntax error if __halt_compiler was not there
?>
12 năm trước ¶
8 năm trước
I don't exactly know what PHP is doing internally but I don't understand the sanity behind how in token_get_all __halt_compiler is handled.
This is actually valid there:
__halt_compiler/**/ /**/ /**/ /**/ /** */();raw
Normally it pops off just any three tokens so you can have even __halt_compiler***, __halt_compiler))), etc in token _get all.
<?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.)
0
<?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.)
1
<?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.)
2
<?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.)
3
<?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.)
4
<?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.)
5
<?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.)
6
Ravenswd tại Gmail Dot Com ¶ ¶
8 năm trước
<?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.)
8
<?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.)
9
Ravenswd tại Gmail Dot Com ¶ ¶
6 năm trước
This function can be used in eval() -- it will halt the eval, but not the script eval"() was called in.
1
This function can be used in eval() -- it will halt the eval, but not the script eval"() was called in.
2