位置: 编程技术 - 正文

PHP:exit()的用法_misc函数(php extract函数)

编辑:rootadmin
exit

推荐整理分享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,不会打印输出。

返回值

没有返回值。

范例

PHP:exit()的用法_misc函数(php extract函数)

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

本文链接地址:https://www.jiuchutong.com/biancheng/284688.html 转载请保留说明!

上一篇:PHP 第二节 数据类型之数值型(php数据表)

下一篇:PHP:__halt_compiler()的用法_misc函数

免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

鄂ICP备2023003026号

网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

友情链接: 武汉网站建设 电脑维修 湖南楚通运网络