当前位置:网站首页>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 begin1
exit(1) No output , End procedure
echo "begin"; exit(1); echo "end"; // Output begin
exit(0) No output , End procedure
echo "begin"; exit(0); echo "end"; // Output begin
exit(‘0’) Output 0 And end the program
echo "begin"; exit('0'); echo "end"; // Output begin0
exit(‘1’) Output 1 And end the program
echo "begin"; exit('1'); echo "end"; // Output begin1
return 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
边栏推荐
- iptables只允许指定ip地址访问指定端口
- 用手机在通达信上开户靠谱吗?这样炒股有没有什么安全隐患
- Numpy -- data cleaning
- Shader_ Animation sequence frame
- 航运船公司人工智能AI产品成熟化标准化规模应用,全球港航人工智能/集装箱人工智能领军者CIMC中集飞瞳,打造国际航运智能化标杆
- 深度之眼(六)——矩阵的逆(附:logistic模型一些想法)
- What are compiled languages and interpreted languages?
- Bidding announcement: 2022 Yunnan Unicom gbase database maintenance public comparison and selection project (second) comparison and selection announcement
- There are many ways to realize the pause function in JS
- U3D_ Infinite Bessel curve
猜你喜欢
Three. JS introductory learning notes 08:orbitcontrols JS plug-in - mouse control model rotation, zoom in, zoom out, translation, etc
Xcode Revoke certificate
What about the pointer in neural network C language
强化实时数据管理,英方软件助力医保平台安全建设
Talk about the cloud deployment of local projects created by SAP IRPA studio
融云斩获 2022 中国信创数字化办公门户卓越产品奖!
Unity3D_ Class fishing project, bullet rebound effect is achieved
Three. JS introductory learning notes 11:three JS group composite object
C4D learning notes 1- animation - animation key frames
深度之眼(七)——矩阵的初等变换(附:数模一些模型的解释)
随机推荐
torch.numel作用
PHP实现微信小程序人脸识别刷脸登录功能
Three. JS introductory learning notes 04: external model import - no material obj model
Sysom case analysis: where is the missing memory| Dragon lizard Technology
Apache Doris刚“毕业”:为什么应关注这种SQL数据仓库?
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"?
SPI master rx time out中断
持续创作,还得靠它!
用手机在通达信上开户靠谱吗?这样炒股有没有什么安全隐患
The unity vector rotates at a point
prometheus api删除某个指定job的所有数据
PyTorch 中的乘法:mul()、multiply()、matmul()、mm()、mv()、dot()
PHP实现执行定时任务的几种思路详解
C4D learning notes 3- animation - animation rendering process case
神经网络c语言中的指针是怎么回事
Unity3d click events added to 3D objects in the scene
过度依赖补助,大客户收款难,冲刺“国产数据库第一股”的达梦后劲有多足?
laravel怎么获取到public路径
Logback logging framework third-party jar package is available for free
Plate - forme de surveillance par étapes zabbix