当前位置:网站首页>The differences between exit, exit (0), exit (1), exit ('0 '), exit ('1'), die and return in PHP
The differences between exit, exit (0), exit (1), exit ('0 '), exit ('1'), die and return in PHP
2022-07-07 16:19:00 【Full stack programmer webmaster】
die(‘1’) die() and exit() All stop script execution functions ; Actually exit and die These two names point to the same function ,die() yes exit() Alias for function . This function only takes one parameter , It can be a numeric value returned by a program or a string , It is also possible to enter no parameters , The result has no return value .
Reference resources : Although the two are the same , But there is also a slight selectivity in use .
When passed to the exit and die The value of the function is 0 when , It means to terminate the execution of the script ahead of time , Usually use exit() The name .
echo "1111"; exit(0); echo "2222";When the program goes wrong , You can pass it a string , It will be output on the system terminal as is , Usually use die() The name .
$fp=fopen("./readme.txt","r") or die(" Cannot open the file "); // In this case , If fopen The function is called to return a Boolean value false when ,die() The script will be terminated immediately , And print it now // The string passed to it ,“ I can say oneortwo words before I die ”.alike die(‘1’) Yetong exit(‘1’) equally , Output 1
echo "begin"; die('1'); echo "end"; // Output begin1exit(1) No output , End procedure
echo "begin"; exit(1); echo "end"; // Output beginexit(0) No output , End procedure
echo "begin"; exit(0); echo "end"; // Output beginexit(‘0’) Output 0 And end the program
echo "begin"; exit('0'); echo "end"; // Output begin0exit(‘1’) Output 1 And end the program
echo "begin"; exit('1'); echo "end"; // Output begin1return Return value , Subsequent procedures are not implemented , Value is not output
echo "begin"; return 1; echo "end"; // Output begin,return The value of is not output to the screen , Instead, it returns to the previous layer summary :
return Is the return value
die It's a mistake that stops
exit It's a direct stop , And do not run subsequent code , exit () You can display content .
return Is the pure return value , But it will not run subsequent code
exit (0): Run the program normally and exit the program ;
exit (1): Abnormal operation causes the program to exit ;
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/113212.html Link to the original text :https://javaforall.cn
边栏推荐
- Laravel 中config的用法
- 通知Notification使用全解析
- 应用程序和matlab的通信方式
- PHP中exit,exit(0),exit(1),exit(‘0’),exit(‘1’),die,return的区别
- JS array foreach source code parsing
- Performance comparison of tidb for PostgreSQL and yugabytedb on sysbench
- js中复选框checkbox如何判定为被选中
- Particle effect for ugui
- Vs tool word highlight with margin
- The unity vector rotates at a point
猜你喜欢

What are compiled languages and interpreted languages?

Eye of depth (VI) -- inverse of matrix (attachment: some ideas of logistic model)

航运船公司人工智能AI产品成熟化标准化规模应用,全球港航人工智能/集装箱人工智能领军者CIMC中集飞瞳,打造国际航运智能化标杆

过度依赖补助,大客户收款难,冲刺“国产数据库第一股”的达梦后劲有多足?

Unity3D_ Class fishing project, bullet rebound effect is achieved

Three. JS introductory learning notes 03: perspective projection camera

AE learning 02: timeline

Apache Doris just "graduated": why should we pay attention to this kind of SQL data warehouse?

Plate - forme de surveillance par étapes zabbix

Good news! Kelan sundb database and Hongshu technology privacy data protection management software complete compatibility adaptation
随机推荐
thinkphp3.2.3中设置路由,优化url
安科瑞电网智能化发展的必然趋势电力系统采用微机保护装置是
招标公告:福建省农村信用社联合社数据库审计系统采购项目(重新招标)
Three. JS introductory learning notes 04: external model import - no material obj model
Dotween -- ease function
[flower carving experience] 15 try to build the Arduino development environment of beetle esp32 C3
应用程序和matlab的通信方式
Bidding announcement: 2022 Yunnan Unicom gbase database maintenance public comparison and selection project (second) comparison and selection announcement
模仿企业微信会议室选择
AE learning 02: timeline
Enterprise log analysis system elk
Notification uses full resolution
Three. JS introductory learning notes 18: how to export JSON files with Blender
47_Opencv中的轮廓查找 cv::findContours()
Excessive dependence on subsidies, difficult collection of key customers, and how strong is the potential to reach the dream of "the first share of domestic databases"?
过度依赖补助,大客户收款难,冲刺“国产数据库第一股”的达梦后劲有多足?
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
讲师征集令 | Apache SeaTunnel(Incubating) Meetup 分享嘉宾火热招募中!
PHP实现微信小程序人脸识别刷脸登录功能
SPI master RX time out interrupt