问题描述:

I've always used the die() function without the 'message' parameter but the function description over at w3schools suggested the 'message' parameter is required.

Must I use the 'message' parameter when using die()?

For example: die( 'Unable to do that' )

Hoping someone can confirm the right way to use the function.

Ref: http://www.w3schools.com/php/func_misc_die.asp

网友答案:

According to the official manual die is equivalent to exit, and exit does not require an argument.

Also, I think lots of people feel that w3schools is not a good source of solid information. (Why?)

And also, exceptions are better (generally, depending of course on what you're doing).

网友答案:

In PHP missing parameters are replaced by null - and since null has a printable string representation (the empty string), it is perfectly legal, while not elegant, to use die();

相关阅读:
Top