当前位置:网站首页>PHP中exit,exit(0),exit(1),exit(‘0’),exit(‘1’),die,return的区别
PHP中exit,exit(0),exit(1),exit(‘0’),exit(‘1’),die,return的区别
2022-07-07 14:07:00 【全栈程序员站长】
die(‘1’) die()和exit()都是中止脚本执行函数;其实exit和die这两个名字指向的是同一个函数,die()是exit()函数的别名。该函数只接受一个参数,可以是一个程序返回的数值或是一个字符串,也可以不输入参数,结果没有返回值。
参考:虽然两者相同,但通常使用中也有细微的选择性。
当传递给exit和die函数的值为0时,意味着提前终止脚本的执行,通常用exit()这个名字。
echo "1111"; exit(0); echo "2222";当程序出错时,可以给它传递一个字符串,它会原样输出在系统终端上,通常使用die()这个名字。
$fp=fopen("./readme.txt","r") or die("不能打开该文件"); //这种情况下,如果fopen函数被调用返回布尔值false时,die()将立即终止脚本,并马上打印 //传递给它的字符串,“死前还能说一两句话”。同样的die(‘1’)也通exit(‘1’)一样,输出1
echo "begin"; die('1'); echo "end"; //输出begin1exit(1) 不输出内容,结束程序
echo "begin"; exit(1); echo "end"; //输出beginexit(0) 不输出内容,结束程序
echo "begin"; exit(0); echo "end"; //输出beginexit(‘0’) 输出0 并结束程序
echo "begin"; exit('0'); echo "end"; //输出begin0exit(‘1’) 输出1 并结束程序
echo "begin"; exit('1'); echo "end"; //输出begin1return 返回值,后续的程序也不执行,值并不输出
echo "begin"; return 1; echo "end"; //输出begin,return的值没有输出到屏幕,而是返回给了上一层总结:
return 是返回值
die是遇到错误才停止
exit 是直接停止,并且不运行后续代码, exit ()可以显示内容。
return 就是纯粹的返回值了,但是也不会运行后续代码
exit (0):正常运行程序并退出程序;
exit (1):非正常运行导致退出程序;
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/113212.html原文链接:https://javaforall.cn
边栏推荐
- Sysom case analysis: where is the missing memory| Dragon lizard Technology
- Detailed explanation of unity hot update knowledge points and introduction to common solution principles
- Limit of total fields [1000] in index has been exceeded
- The unity vector rotates at a point
- hellogolang
- 用手机在通达信上开户靠谱吗?这样炒股有没有什么安全隐患
- 深度之眼(六)——矩阵的逆(附:logistic模型一些想法)
- 2022第四届中国(济南)国际智慧养老产业展览会,山东老博会
- prometheus api删除某个指定job的所有数据
- Postman generate timestamp, future timestamp
猜你喜欢

Xingruige database was shortlisted as the "typical solution for information technology application and innovation in Fujian Province in 2021"

山东老博会,2022中国智慧养老展会,智能化养老、适老科技展

SPI master rx time out中断

Lecturer solicitation order | Apache seatunnel (cultivating) meetup sharing guests are in hot Recruitment!

Wireless sensor networks -- ZigBee and 6LoWPAN

MySQL数据库基本操作-DQL-基本查询

深度之眼(六)——矩阵的逆(附:logistic模型一些想法)

喜讯!科蓝SUNDB数据库与鸿数科技隐私数据保护管理软件完成兼容性适配

航運船公司人工智能AI產品成熟化標准化規模應用,全球港航人工智能/集裝箱人工智能領軍者CIMC中集飛瞳,打造國際航運智能化標杆

Numpy -- epidemic data analysis case
随机推荐
Three singleton modes of unity (hungry man, lazy man, monobehavior)
Performance measure of classification model
Unity drawing plug-in = = [support the update of the original atlas]
Iptables only allows the specified IP address to access the specified port
Syntaxhighlight highlights the right scroll bar
Odoo集成Plausible埋码监控平台
Detailed explanation of unity hot update knowledge points and introduction to common solution principles
10 schemes to ensure interface data security
分步式監控平臺zabbix
Unity的三种单例模式(饿汉,懒汉,MonoBehaviour)
L'application à l'échelle de la normalisation mature des produits ai des compagnies maritimes, cimc, leader mondial de l'intelligence artificielle portuaire et maritime / intelligence artificielle des
安科瑞电网智能化发展的必然趋势电力系统采用微机保护装置是
SysOM 案例解析:消失的内存都去哪了 !| 龙蜥技术
Three. Introduction to JS learning notes 17: mouse control of 3D model rotation of JSON file
A JS script can be directly put into the browser to perform operations
Good news! Kelan sundb database and Hongshu technology privacy data protection management software complete compatibility adaptation
Sysom case analysis: where is the missing memory| Dragon lizard Technology
C4D learning notes 3- animation - animation rendering process case
Wireless sensor networks -- ZigBee and 6LoWPAN
TiDB For PostgreSQL和YugabyteDB在Sysbench上的性能对比