Including files with possible syntax errors...
Posted: Sun Feb 01, 2009 12:53 pm
Hi Guys,
I'm working on script that includes others scripts in another folder which they could have a syntax error. I'm reading php arrays in those scripts. What I want to do it's to catch that error when before opening or while opening the script so I can prevent the script from stopping.
For example:
The previous array is missing a comma after the number two. I tried to catch that error with an error handler but it still stops the script and It doesn't catch the error.
A handler to catch errors would look something like this:
So if I do:
I get a warning and the script stops.
Any ideas? All possible help will be appreciated, Thanks
I'm working on script that includes others scripts in another folder which they could have a syntax error. I'm reading php arrays in those scripts. What I want to do it's to catch that error when before opening or while opening the script so I can prevent the script from stopping.
For example:
Code: Select all
<?php
$arr = array("one")=>1, "two"=> 2 "three"=>3);
?>
A handler to catch errors would look something like this:
Code: Select all
<?php
set_error_handler('oops');
function oops($type, $msg, $file, $line, $context) {
echo $type.$msg.$file, $line.$context;
}
?>
Code: Select all
<?php
set_error_handler('oops');
$arr = array("one")=>1, "two"=> 2 "three"=>3);
function oops($type, $msg, $file, $line, $context) {
echo $type.$msg.$file, $line.$context;
}
?>
Any ideas? All possible help will be appreciated, Thanks