我非常新的PHP和我试图写该功能。现在看起来这个函数没有定义。当我打开php文件并且如果我尝试使用控制台运行它时,什么都不会发生。它给出了一个错误 -的ReferenceError,函数未定义
内容检查( 'ex1.php', 'Bajestani')
的ReferenceError:内容检查未定义
的代码如下。
<?php
if(contentcheck('ex1.php','Bajestani')===true)
echo 'Got it';
function contentcheck($filename,$phrase)
{
$content = shell_exec('C:\xampp\htdocs\docman\pdftotext '.$filename.' -');
if (strpos($content,$phrase) !== false)
{
return true;
}
else
return false;
}
if(contentcheck('ex1.php','Bajestani')===true)
echo 'Got it';
?>
在此先感谢
你执行它的JS或PHP?因为它似乎将其放入脚本标记 – bwoebi
“ReferenceError:X未定义”是一个JavaScript错误 - 不是PHP错误。要建立@ bwoebi的评论,你是否试图从javascript调用'contentcheck()'? – newfurniturey