Recently I think about some sort of safe includes which will not fail
if parse error happened. And many different sourses said that this is
imposible without some non standard modules and without calling "perl
-l"
I made some investigation and found this way:
function check_syntax($f ilename)
{
// load file
$code = file_get_conten ts($file);
// remove non php blocks
$code = preg_replace('/(^|\?>).*?(<\?p hp|$)/i', '', $code);
// create lambda function
$f = @create_functio n('', $code);
// return function error status
return !empty($f);
}
This function will return true if code ok or false if not. Maybe it
will be usefull for somebody...
WBR,
Dima Vidmich
if parse error happened. And many different sourses said that this is
imposible without some non standard modules and without calling "perl
-l"
I made some investigation and found this way:
function check_syntax($f ilename)
{
// load file
$code = file_get_conten ts($file);
// remove non php blocks
$code = preg_replace('/(^|\?>).*?(<\?p hp|$)/i', '', $code);
// create lambda function
$f = @create_functio n('', $code);
// return function error status
return !empty($f);
}
This function will return true if code ok or false if not. Maybe it
will be usefull for somebody...
WBR,
Dima Vidmich