How to run a external program in PHP?

PHP - How to keep program still run when have error

Phi Tống at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

I would try something like: <?php for ($i = 1; $i <=20; $i++) { echo $i . '<br />'; if ($i == 10) { if ($haha) $haha->hoho("hehe"); } } ?> This should check if $haha exists before it tries to do $haha->hoho("hehe");

Mike Lentini

You can use try and catch block. An exception is thrown, when you call a method on non-object. See http://php.net/manual/en/language.exceptions.php for exeptions in php. <?php for ($i = 1; $i <=20; $i++) { echo $i . '<br />'; try { if ($i == 10) { $haha->hoho("hehe"); } } catch(Exception $e) { //handle the error... } } ?>

Jaa-c

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.