How PHP catches errors

Source: Internet
Author: User
Tags php error try catch
How does PHP catch exceptions?
How does PHP catch exceptions?
Are there similar. NET Try catch mechanisms?
PHP does not have to debug the egg row by line!
------Solution--------------------
Some have the same wording.
try {

} catch (Exception $e) {
Print $e->getmessage ();

}
------Solution--------------------
Reference: are
there any similar. NET Try catch mechanisms?
This really has ~
Reference:
PHP can not be debugged on a line of egg pain!
Landlord did not find the IDE
------Solution--------------------
In fact, PHP debugging can be adjusted at any time, where you want to tune, the simplest is where the output. Of course Zend-studio also provides a breakpoint function debugging, but far less convenient.
In fact, each has its own advantages, brother, or from the bar.
------Solution--------------------
#1 Cute Arctic Bear Solution
------Solution--------------------
You also need to throw an exception in the try{} statement block, throw new Exception (' It is a exception! '), and then capture by catch (Exception $e).
------Solution--------------------
Use Echo to find the anomaly, PHP can't.
------Solution--------------------
Then go to see PHP error_log ah ... There will be a variety of detailed error messages .... What else can catch ...
------Solution--------------------
There are basically two types of errors, one that can be captured by PHP, such as syntax errors. There is also a logical error that the machine does not capture, so the try catch is used to capture the artifact.
I think you said the error is just the previous one, then open the error prompt display_errors = On, you can see.
------Solution--------------------
The basic question in the top post is how to open the error message.
------Solution--------------------
and a set_exception_handle.
------Solution--------------------
Your code is no exception, of course, will not execute that sentence

Reference:
PHP Code

try{
$a = "SGFDFGDF";
$b = (int) $a;
Echo ($b);
}
catch (Exception $e) {
Echo ("Error". $e->getmessage ());//Here and the wood is executed.
}

------Solution--------------------
Cough, this is not wrong, in PHP, automatic conversion

References:
References:

Your code is no exception, of course, will not execute that sentence

Reference:

PHP Code

try{
$a = "SGFDFGDF";
$b = (int) $a;
Echo ($b);
}
catch (Exception $e) {
Echo ("Error". $e->getmessage ());//Here and the wood is executed.
...

------Solution--------------------
References:
shaping Conversion Errors It's not a mistake.
Coercion of type conversions is not an error in any language!
Although sometimes you don't get the results you expect.
------Solution--------------------
PHP error exceptions are similar to Java, but they are usually thrown on their own: examples:
try{
$m = 0;
if ($m < 1) {
throw new Exception (' m= '. $m. ': Less than 0 ');
}
Echo $m;
} catch (Exception $e) {
echo "Error [line->". ( $e->getline ()). "]:". ($e->getmessage ());
}
------Solution--------------------
PHP Weak type change data type no problem
------Solution--------------------
Let the divisor be 0, and you'll see the throw anomaly.
  • Contact Us

    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

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.