致命错误:调用file.php错误/定义函数中的未定义函数

时间:2013-09-11 11:05:41

标签: php undefined-function

我有一个在2007年开发的网站。我一直在使用这个网站没有问题,但最近我有一个像下面的PHP错误:

Fatal error: Call to undefined function getTitle() in comments.php error on line 3

$ptitle = htmlspecialchars(getTitle($row_cs['id'])); // line 3

此函数在funcs.php文件中定义。

以下是我使用include;

的文件

的index.php

include 'funcs.php'
...
...
...
include 'comments.php'

funcs.php

function getTitle($tid)
{
    $sql = mysql_query("select title from table where id = '".$tid."'");
    $title = mysql_fetch_row($sql);

    return $title[0];
}

我在comments.php中调用getTitle()方法 我没有直接在comments.php中包含funcs.php 两个文件(funcs.php和comments.php)都包含在index.php中。我通常在comments.php文件中使用funcs.php方法。

为什么我最近收到此错误,这是服务器配置问题吗?

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

请使用单引号包含文件。

include 'func.php';
include 'comments.php';