当前位置:网站首页>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
边栏推荐
- 95. (cesium chapter) cesium dynamic monomer-3d building (building)
- MySQL数据库基本操作-DQL-基本查询
- Logback logging framework third-party jar package is available for free
- Eye of depth (VI) -- inverse of matrix (attachment: some ideas of logistic model)
- js中复选框checkbox如何判定为被选中
- 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
- Aerospace Hongtu information won the bid for the database system research and development project of a unit in Urumqi
- [excelexport], Excel to Lua, JSON, XML development tool
- Unity drawing plug-in = = [support the update of the original atlas]
- Regular expression string
猜你喜欢

Shandong old age Expo, 2022 China smart elderly care exhibition, smart elderly care and aging technology exhibition

分步式監控平臺zabbix

Numpy -- epidemic data analysis case

企业级日志分析系统ELK

C4D learning notes 3- animation - animation rendering process case

Multiplication in pytorch: mul (), multiply (), matmul (), mm (), MV (), dot ()

Talk about the cloud deployment of local projects created by SAP IRPA studio
![[flower carving experience] 15 try to build the Arduino development environment of beetle esp32 C3](/img/8f/ca9ab042916f68de7994d9f2124da9.jpg)
[flower carving experience] 15 try to build the Arduino development environment of beetle esp32 C3

Three. JS introductory learning notes 15: threejs frame animation module

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
随机推荐
Lecturer solicitation order | Apache seatunnel (cultivating) meetup sharing guests are in hot Recruitment!
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
JS array foreach source code parsing
ThinkPHP URL 路由简介
nodejs package. JSON version number ^ and~
MySQL中, 如何查询某一天, 某一月, 某一年的数据
Three. JS introductory learning notes 00: coordinate system, camera (temporarily understood)
Performance measure of classification model
Logback logging framework third-party jar package is available for free
山东老博会,2022中国智慧养老展会,智能化养老、适老科技展
喜讯!科蓝SUNDB数据库与鸿数科技隐私数据保护管理软件完成兼容性适配
神经网络c语言中的指针是怎么回事
How to determine whether the checkbox in JS is selected
【知识小结】PHP使用svn笔记总结
Laravel 服务提供者实例教程 —— 创建 Service Provider 测试实例
There are many ways to realize the pause function in JS
修改配置文件后tidb无法启动
10 schemes to ensure interface data security
Step by step monitoring platform ZABBIX
Three. JS introductory learning notes 11:three JS group composite object