Asked by duncanb7
at 2024-04-27 05:43:46
Point:500 Replies:13 POST_ID:828490USER_ID:11059
Topic:
PHP Scripting Language;JavaScript;Visual Basic Programming
For Error handling, for example, in VBA, we can have "On Error Resume Next" or "On Error Goto" to
let the program still in running even the error happen at exact line number.
In Javascript, that is also easily to understand the error handling from try and catch{}, if error happen
in try {} and then goto catch();
But for my php I am trying using try and catch{} that is NOT exactly same as method as in javascript or VBA handling.
I get an error message from the following php code : Fatal error: Call to a member function
getElementByTagName() on a non-object on line 10 ,which is exact same line at $data= $dom->getElementsByTagName('table')->item(4)->getElementsByTagName('div')->item(21)>nodeValue;
In my code, I try to access the remote-site with $c varaible to program the $url, there is 10 pages I need to
grab the data, if one of fail, I will re-do it until 5 times is fail.
I don't care the fatal error but it will halt the program running or suspend everything , Why I don't care
because I know it is remote-site server is busy only to handle my request of LoadHTMLFile().
Now I put try and catch {} to let it re-do again for 4 more times once fatal error happen, But
it still get the same line ans same fatal error message and quit the program right away, in other words,
it never go to catch{}.
Please advise, how to let the following code running even fatal-error because I can re-do 4 more time and then
quit the program. I know at least one time success on LoadHTMlfile() work in 5 trial.
There is a lot of Error handling at http://php.net/manual/en/function.set-error-handler.php,
I don't how it works becuase I know once the fatal-error happen, the program will quit so how to
do any if or condition check for the error happen location.
Duncan
let the program still in running even the error happen at exact line number.
In Javascript, that is also easily to understand the error handling from try and catch{}, if error happen
in try {} and then goto catch();
But for my php I am trying using try and catch{} that is NOT exactly same as method as in javascript or VBA handling.
I get an error message from the following php code : Fatal error: Call to a member function
getElementByTagName() on a non-object on line 10 ,which is exact same line at $data= $dom->getElementsByTagName('table')->item(4)->getElementsByTagName('div')->item(21)>nodeValue;
In my code, I try to access the remote-site with $c varaible to program the $url, there is 10 pages I need to
grab the data, if one of fail, I will re-do it until 5 times is fail.
I don't care the fatal error but it will halt the program running or suspend everything , Why I don't care
because I know it is remote-site server is busy only to handle my request of LoadHTMLFile().
Now I put try and catch {} to let it re-do again for 4 more times once fatal error happen, But
it still get the same line ans same fatal error message and quit the program right away, in other words,
it never go to catch{}.
Please advise, how to let the following code running even fatal-error because I can re-do 4 more time and then
quit the program. I know at least one time success on LoadHTMlfile() work in 5 trial.
There is a lot of Error handling at http://php.net/manual/en/function.set-error-handler.php,
I don't how it works becuase I know once the fatal-error happen, the program will quit so how to
do any if or condition check for the error happen location.
Duncan