Connecting Tech Pros Worldwide Forums | Help | Site Map

How to stop code execution when an error is found on a function, fromwithin the function... It's hard to explain, just read...

Bruno Rafael Moreira de Barros
Guest
 
Posts: n/a
#1: Jan 14 '08
index.php
---
inlcude 'application.php';


functions.php
---
function test1() {
trigger_error('My error');
return FALSE;
}


application.php
---
eval('
//code...
test1();
//code...
');

What I want is to stop the eval as soon as test1() errors, without
having to do ifs on the eval'd code. Is there any chance, or do I
really have to do:

eval('
//code...
if (test1()) {

} else {
return;
}
//code...
');

What's the code I should use on test1()? Because I can't control the
eval'd code (because it's written by other developers), but I can
control test1() and index.php, and I want test1() to stop the eval'd
code so index.php can continue working (cleaning the output buffer of
the eval'd code and outputting an error message). Is there any chance
of doing that?

Bruno Rafael Moreira de Barros
Guest
 
Posts: n/a
#2: Jan 14 '08

re: How to stop code execution when an error is found on a function, fromwithin the function... It's hard to explain, just read...


On Jan 14, 11:02 am, Bruno Rafael Moreira de Barros
<brunormbar...@gmail.comwrote:
Quote:
index.php
---
inlcude 'application.php';
>
functions.php
---
function test1() {
trigger_error('My error');
return FALSE;
>
}
>
application.php
---
eval('
//code...
test1();
//code...
');
>
What I want is to stop the eval as soon as test1() errors, without
having to do ifs on the eval'd code. Is there any chance, or do I
really have to do:
>
eval('
//code...
if (test1()) {
>
} else {
return;
}
>
//code...
');
>
What's the code I should use on test1()? Because I can't control the
eval'd code (because it's written by other developers), but I can
control test1() and index.php, and I want test1() to stop the eval'd
code so index.php can continue working (cleaning the output buffer of
the eval'd code and outputting an error message). Is there any chance
of doing that?
Exceptions will probably do the trick. The other post I have made has
actually solved the problem with this one as well. Thanks anyway.
Mason Barge
Guest
 
Posts: n/a
#3: Jan 15 '08

re: How to stop code execution when an error is found on a function, fromwithin the function... It's hard to explain, just read...



"Bruno Rafael Moreira de Barros" <brunormbarros@gmail.comwrote in message
news:8d9b85cb-a830-44cf-a8ef-cae3e3eee8fa@q39g2000hsf.googlegroups.com...
Quote:
index.php
---
inlcude 'application.php';
>
>
functions.php
---
function test1() {
trigger_error('My error');
return FALSE;
}
>
>
application.php
---
eval('
//code...
test1();
//code...
');
>
What I want is to stop the eval as soon as test1() errors, without
having to do ifs on the eval'd code. Is there any chance, or do I
really have to do:
>
eval('
//code...
if (test1()) {
>
} else {
return;
}
//code...
');
>
What's the code I should use on test1()? Because I can't control the
eval'd code (because it's written by other developers), but I can
control test1() and index.php, and I want test1() to stop the eval'd
code so index.php can continue working (cleaning the output buffer of
the eval'd code and outputting an error message). Is there any chance
of doing that?
check the manual on "continue;".

Closed Thread