从另一个php文件调用未定义的函数
发布时间:2020-12-13 17:19:34 所属栏目:PHP教程 来源:网络整理
导读:好吧,这就是我的代码 的index.php require_once($WebsiteRoot . "/include/testfile.php");TestFunction(); /include/testfile.php function TestFunction(){ echo "It Works";} 它给了我错误: Fatal error:Call to undefined function TestFunction() in /
好吧,这就是我的代码
的index.php require_once($WebsiteRoot . "/include/testfile.php"); TestFunction(); /include/testfile.php function TestFunction() { echo "It Works"; } 它给了我错误: Fatal error: Call to undefined function TestFunction() in /path/index.php on line 49 知道我做错了什么吗? 解决方法
确保包含您认为自己的文件.如果您的index.php页面看起来与您所说的完全一样,那么它将不会返回任何内容.
如果要从站点的任何位置链接到同一位置而不必担心相对位置,则在文件的开头放置: $WebsiteRoot=$_SERVER['DOCUMENT_ROOT']; 如果您的文件位于http://mywebsite.com/include/testfile.php,它应该可以正常工作 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |