dqz7636 2014-10-05 19:13
浏览 29

PHP'包含'功能错误

I receive the following error when including a widget;

Warning: include(/includes/template/widgets/leftNavigator.php): failed to open stream: No such file or directory in C:\inetpub\wwwroot\includes\lib\widgets\class.widgets.php on line 8

when running it through using:

public static function getWidget($name) {
    ob_start
        include("/includes/template/widgets/" . strtolower($name) . ".php");
        $content = ob_get_contents();
    ob_end_clean();
    return $content;
}

....
ClassName::getWidget("leftNavigator");

but if I change it too:

public static function getWidget($name) {
    ob_start
        include("/includes/template/widgets/leftNavigator.php");
        $content = ob_get_contents();
    ob_end_clean();
    return $content;
}

it will work fine.

It is called in the files using;

$this->html = preg_replace('~\{widget.(\w+)\}~', Widget::getWidget("$1"), $this->html);

After removing 'strtolower(..)', I still receive the error.

  • 写回答

1条回答 默认 最新

  • douzhi2760 2014-10-05 23:35
    关注

    Your files are case sensitive when including other content. Your file has a capital N and strtolower($name) just make all the characters lower case. Instead of having strtolower($name) just do $name or something else.

    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向