Leave php for routine use without exception handling
Source: Internet
Author: User
Leave php everyone does not need to handle errors everyday. my younger brother used java exceptions before. I had to capture a program and write it for 20 minutes to handle exceptions. About half of the time. Recently, I saw that php also supports trycatch, but it seems like I have not embroidered my pillow. I found some practical significance. I wonder if I am a newbie. I hope that the php Daniel can give me a practical example of phptrycatch processing or ask for leave. php is not used for error handling in daily use.
Before using java exceptions, the younger brother must capture and write a program. It takes about half of the time to handle exceptions in 20 minutes.
Recently I saw php and found that php also supports try catch, but it seems that I have not found any practical significance.
I wonder if I am a newbie. I hope that the php Daniel can give me a practical example of php try catch processing or I am grateful for it! We are sincere to you!
------ Solution --------------------
I usually check the file before it is included. if the file does not exist, an exception is thrown, and the error page is beautified. Or you want to unify the handling methods used after the error.
Of course, this is useful in some complex systems, such as extending exceptions to find trace function call steps. But in general, this is indeed an embroidered pillow.
------ Solution --------------------
This is really not very useful. I usually cannot use what I write.
According to this article by laruence, lz should have some gains after reading it.
Http://www.laruence.com/2012/02/02/2515.html
------ Solution --------------------
You don't need to try... catch. if something goes wrong, php will tell you where the error is. At most, if else determines.
------ Solution --------------------
I am surprised to say this by writing java ......
Php try... catch refers to learning from java and so on, and its usage is similar... I don't know why you think "discover some practical significance"
Discussion
Before using java exceptions, the younger brother must capture and write a program. It takes about half of the time to handle exceptions in 20 minutes.
Recently I saw php and found that php also supports try catch, but it seems that I have not found any practical significance.
I wonder if I am a newbie. I hope that the php Daniel can give me a practical example of php try catch processing or I am grateful for it! We are sincere to you!
------ Solution --------------------
Php try catch is rarely used. If something goes wrong, php usually reports an error!
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