[PHP-WIN] Simple error handling/catching/avoidance

2012-06-08 Thread Jacob Kruger
Just wondering why the following code actually renders an error message instead of just then invoking the catch clause: //start code $iVar1 = 0; $iVar2 = 10; try { echo $iVar2 / $iVar1; } catch (Exception $e) { echo "No division by zero allowed"; } //end of code Stay well Jacob Kruger Blind Bik

Re: [PHP-WIN] Simple error handling/catching/avoidance

2012-06-08 Thread Keith Davis
It's the reason why I can't stand exceptions in PHP, we talked about this a bunch at our meeting on Wednesday. You still have to suppress the error through one of several methods (using @ or custom error handler that does not display it) AND then you have to throw an exception manually. I fact

Re: [PHP-WIN] Simple error handling/catching/avoidance

2012-06-08 Thread Jacob Kruger
Yup. That bit of obvious error-generating code was also just an example of something that would definitely generate an error/exception, since current actual issue is that am meant to be using/operating within someone else's sort of containing framework/wrappers, and means can't always be sure

Re: [PHP-WIN] Simple error handling/catching/avoidance

2012-06-08 Thread Jacob Kruger
Ok, and, along the lines of this, I also get the following error/exception when I try to determine if a function is defined using function_exists(): Fatal error: Undefined class constant 'getUserDepartment' in /var/www/business/products/attendance.php on line 52 The other difference there is th

RE: [PHP-WIN] Simple error handling/catching/avoidance

2012-06-08 Thread Keith Davis
Oh, I agree and working with C# makes me really understand how limited the PHP exception / error handling process is. Keith Davis (214) 906-5183 -Original Message- From: Jacob Kruger [mailto:ja...@blindza.co.za] Sent: Friday, June 08, 2012 8:39 AM To: php-windows@lists.php.net Cc: php-wi

RE: [PHP-WIN] Simple error handling/catching/avoidance

2012-06-08 Thread Keith Davis
I'm confused. Can't you just use method_exists(array("Security", " getUserDepartment"))? If that throws an error because of class, then just suppress it (@). Keith Davis (214) 906-5183 -Original Message- From: Jacob Kruger [mailto:ja...@blindza.co.za] Sent: Friday, June 08, 2012 9:24 A

RE: [PHP-WIN] Simple error handling/catching/avoidance

2012-06-08 Thread Toby Hart Dyke
The problem is noted here (http://www.php.net/manual/en/language.exceptions.php): >Internal PHP functions mainly use Error reporting, only modern Object oriented extensions use exceptions. However, errors can be simply translated to exceptions with >ErrorException. One possible solution (noted h