dousi6405 2010-11-11 03:36
浏览 30
已采纳

定义的PHP函数返回未定义的函数

I have a functions.php page with some functions, it is required in the default.php page 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.

  • 写回答

2条回答 默认 最新

  • dongqiang5932 2010-11-11 03:50
    关注

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题