Often see such statements:
$file = fopen ($filename, ' r ') or Die ("Sorry, unable to open: $filename");
Or here is the understanding, because in PHP does not distinguish between the data type, so $file can be int also can bool, so such statements do not complain. But the process may not be clear to some friends.
In most languages, in a statement like BOOL or bool, a value is not judged if the previous value is true. So is this, so if the fopen function executes correctly, it returns an int value greater than 0 (which is actually "true"), and the following statement is not executed. If the fopen function fails, it returns false, and the subsequent expression is judged to be true.
After the result executes die (), the program stops executing regardless of what is returned, and displays the specified error message, which is the purpose of debugging.
That's it. :)
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service