开发者

Defined PHP function returns function undefined

I have a functions.php page with some functions, it is required in the default.php pa开发者_运维技巧ge which is required by all my other pages (index.php) at the first line.

index.php (1st line after <?php

require("includes/default.php");

default.php

<?php
//mysql
require("templates.php");
require("functions.php");
?>

functions.php

<?php

function rating_format($num) {
    if ($num > 0) {
        return "+" . $num;
    }
    elseif ($num < 0) {
        return "-" . $num;
    }
    else {
        return $num;
    }
}

function thumbnail_url($value) {
    if ($value == "") {
        return "no_favicon.png";
    }
    else {
        return $value;
    }
}
?>

I use both functions defined in functions.php in index.php. However, only the second function seems to be defined. Whenever trying to use the first function, it spits out an function undefined error.

I've rearranged the code several times and don't know what is wrong with it. The function is defined before I even use it.

Any help is appreciated.


Try changing the name of the functions.php file to something more unique / less generic, like rating.fcns.php.


I would start by replacing the includes with the actual code for the time being, just to see if the issue is with your includes or your functions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜