5.0之前有个函数php_check_syntax,5.0之后没有了,我们可以自己写
<?php
if (!function_exists('php_check_syntax')) {
//php 5.0开始内置的函数废除了,我们可以自己写一个
function php_check_syntax($file_content, &$error_message = null) {
// $file_content = file_get_contents($file_name);
$check_code = "return true; ?>";
$file_content = $check_code . $file_content . "<?php ";
if (!@eval($file_content)) {
$error_message = "code err";
return false;
}
return true;
}
}
if (!php_check_syntax("<?ss=12?>", $msg)) {
echo $msg;
} else {
echo "no problem";
}
?>
网友回复