php中die和exit,PHP中的die()和exit()有什么区别?

文章目录

die()和exit()函数在PHP中有什么区别?

我认为两者都具有相同的功能,但是我怀疑这两者有什么不同…这是什么?

没有区别 - 他们是一样的。

PHP手册exit:Note: This language construct is equivalent to

die().

PHP手册die:This language construct is equivalent to

exit().

PHP中die()和exit()的区别是它们的起源。

exit()从exit()在C. die()来自Perl中的die。

FUNCTIONALLY EQUIVALENT

die()和exit()是等效的功能。

PHP Manual

PHP手册die:This language construct is equivalent to

exit().

PHP手册exit:Note: This language construct is equivalent to

die().

函数别名列表的PHP手册:die is an alias for master

function exit()

DIFFERENT IN OTHER LANGUAGES

die()和exit()在其他语言是不同的,但在PHP中它们是相同的。

从另一个PHP的咆哮:…As a C and Perl coder, I was ready to answer, “Why, exit() just bails off

the program with a numeric exit status, while die() prints out the error

message to stderr and exits with EXIT_FAILURE status.” But then I remembered

we’re in messy-syntax-land of PHP.

>In PHP, exit() and die() are identical.

>The designers obviously thought “Hmm, let’s borrow exit() from

C. And Perl folks probably will

like it if we take die() as is from

Perl too. Oops! We have two exit

functions now! Let’s make it so that they both can take a string or integer as

an argument and make them identical!”

>The end result is that this didn’t really make things any “easier”, just

more confusing. C and Perl coders will continue to use exit() to toss an

integer exit value only, and die() to toss an error message and exit with a

failure. Newbies and PHP-as-a-first-language people will probably wonder “umm,

two exit functions, which one should I use?” The manual doesn’t explain why

there’s exit() and die().

>In general, PHP has a lot of weird redundancy like this - it tries to be

friendly to people who come from different language backgrounds, but while

doing so, it creates confusing redundancy.

未经作者同意,本文严禁转载,违者必究!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值