您现在的位置是: 网站首页> PHP PHP

PHP程序终止时执行函数

杨二桃 2021-06-01 PHP 1551人已围观

简介PHP程序终止时执行函数

1.程序终止时执行函数:register_shutdown_function()

一般用法:

<?php 
function test(){
    echo 'text终止输出';
}
 
//程序终止执行  
register_shutdown_function('test'); 

echo 'HELLO WORLD !' . PHP_EOL;


////运行结果

HELLO WORLD !
text终止输出

调用其他类方法:

//register_shutdown_function([new 类名,‘方法名’])
register_shutdown_function([new Test,'test'])

很赞哦! ({{ infoItems.like }})