位置: 编程技术 - 正文
推荐整理分享PHP:exit()的用法_misc函数(php extract函数),希望有所帮助,仅作参考,欢迎阅读内容。
文章相关热门搜索词:php executable,php extract函数,php中exit后怎样继续执行,php中exit后怎样继续执行,php中exit(),php executable,php中exit后怎样继续执行,php中exit后怎样继续执行,内容如对您有帮助,希望把文章链接给更多的朋友!
(PHP 4, PHP 5)
exit — 输出一个消息并且退出当前脚本
说明 void exit ([ string $status ] ) void exit ( int $status )中止脚本的执行。 尽管调用了 exit(), Shutdown函数 以及 object destructors 总是会被执行。
参数status
如果 status 是一个字符串,在退出之前该函数会打印 status 。
如果 status 是一个 integer,该值会作为退出状态码,并且不会被打印输出。 退出状态码应该在范围0至,不应使用被PHP保留的退出状态码。 状态码0用于成功中止程序。
Note: PHP >= 4.2.0 当 status 是一个 integer,不会打印输出。
返回值没有返回值。
范例
Example #1 exit() 例子
<?php$filename='/path/to/data-file';$file=fopen($filename,'r')orexit("unabletoopenfile($filename)");?>
Example #2 exit() 状态码例子
<?php//exitprogramnormallyexit;exit();exit(0);//exitwithanerrorcodeexit(1);exit();//octal?>
Example #3 无论如何,Shutdown函数与析构函数都会被执行
<?phpclassFoo{publicfunction__destruct(){echo'Destruct:'.__METHOD__.'()'.PHP_EOL;}}functionshutdown(){echo'Shutdown:'.__FUNCTION__.'()'.PHP_EOL;}$foo=newFoo();register_shutdown_function('shutdown');exit();echo'Thiswillnotbeoutput.';?>以上例程会输出:
注释Note: 因为是一个语言构造器而不是一个函数,不能被可变函数 调用。
Note:
该语法结构等同于 die()。
参见register_shutdown_function() - Register a function for execution on shutdown
PHP:__halt_compiler()的用法_misc函数 __halt_compiler(PHP5=5.1.0)__halt_compiler中断编译器的执行说明void__halt_compiler(void)中断编译器的执行。常用于在PHP脚本内嵌入数据,类似于安装文件。可以通过
PHP:die()的用法_misc函数 die(PHP4,PHP5)die等同于exit()说明语法结构等同于exit().
PHP:defined()的用法_misc函数 defined(PHP4,PHP5)defined检查某个名称的常量是否存在说明booldefined(string$name)检查该名称的常量是否已定义。Note:如果你要检查一个变量是否存在,请使用isset
标签: php extract函数
本文链接地址:https://www.jiuchutong.com/biancheng/284688.html 转载请保留说明!友情链接: 武汉网站建设