douzhang2680 2015-07-20 10:14
浏览 56
已采纳

包含一个公共文件只在一个文件Codeigniter中失败

i am including "navigation.php" which has the common menu in all my views .

<div id="navigation">
    <? include("navigation.php"); ?>
</div>

this code works in every other files but in one file it gives errors .

Severity: Warning
Message: include(navigation.php): failed to open stream: No such file or directory
Filename: views/readsinvo_index.php
Line Number: 2


Severity: Warning
Message: include(): Failed opening 'navigation.php' for inclusion (include_path='.:/usr/share/pear:/usr/share/php')
Filename: views/readsinvo_index.php
Line Number: 2

in "readsinvo_index.php" it is same as the other files

<div id="navigation">
    <? include("navigation.php"); ?>
</div>

and both the files are inside "views" . both files have permission 777 .

But when i tried with

<? include(dirname(__FILE__)."/navigation.php"); ?>

It works perfectly , but in all other pages , it is working when used

<? include("navigation.php"); ?>

is there any possible reason that i cannot include the file normally only in this file . I am using codeigniter framework and CentOS .

  • 写回答

2条回答 默认 最新

  • dongzai2952 2015-07-20 11:19
    关注

    You can use APPPATH

    APPPATH.'views/navigation.php'
    

    And Possible duplicate of how call another php file to Codeigniter view

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

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?