is there a way to catch parse errors in included files?
Posted: Tue Mar 23, 2004 9:28 pm
is there a way to catch parse errors in included files?
is there a way that i can include a file and know whether it worked nicely?
i have a function that loads custom classes for different purposes
and i'd like something like this
(but not actually this because i don't believe include() actually returns anything that is useful to me)
if the include does not work i dont want my program to crash, just gracefully not use the class defined in the included file
any one got any suggestions?
cheers
mathew
is there a way that i can include a file and know whether it worked nicely?
i have a function that loads custom classes for different purposes
and i'd like something like this
(but not actually this because i don't believe include() actually returns anything that is useful to me)
Code: Select all
$file = "giantmonkeys.php";
if(file_exists($file))
{
if (include("$file"))
{
echo "<br>it worked!";
// then do some thing useful with the functions and classes
// included in the file
}
else
{
echo "<br>hmm.. something seems to have gone wrong";
//gracefully continue on without included functions and classes
}
}any one got any suggestions?
cheers
mathew