繁体   English   中英

带有load()和视图的错误codeigniter

[英]error codeigniter with load() and views

下午好,

我对CodeIgniter的load()方法有问题。 在当地一切工作都很棒。 但是,当我尝试在在线服务器上检查我的应用程序时,出现问题<=> 无法加载请求的文件:警告/信息

我发现的解决方案是执行此操作<=>

(1)在当地

public function test() {
         $this->load->view('warning/info');
    }

(2)在在线服务器中,我必须像这样指定扩展名

public function test() {
     $this->load->view('warning/info.php');
}

我不知道为什么我必须放弃这个? 如果有人知道你为什么可以向我解释。

非常感谢您,对不起我的英语不流利,但我希望您能理解我的信息。

找出问题

我在_ci_load()方法中查看了system / core / Loader.php ,并且提取了似乎引起您问题的代码:

#/system/core/Loader.php::_ci_load

$_ci_ext = pathinfo($_ci_view, PATHINFO_EXTENSION);
$_ci_file = ($_ci_ext == '') ? $_ci_view.'.php' : $_ci_view;

foreach ($this->_ci_view_paths as $view_file => $cascade)
{
        if (file_exists($view_file.$_ci_file))
        {
                $_ci_path = $view_file.$_ci_file;
                $file_exists = TRUE;
                break;
        }

        if ( ! $cascade)
        {
                break;
        }
}

....

if ( ! $file_exists && ! file_exists($_ci_path))
{
        show_error('Unable to load the requested file: '.$_ci_file);
}

解决问题

我看过使用的方法,它们似乎都支持PHP 4.0.3以上,因此您的问题很可能与不兼容的PHP版本无关。

似乎触发您的问题的代码在这里:

if ( ! $file_exists && ! file_exists($_ci_path))
{
        show_error('Unable to load the requested file: '.$_ci_file);
}

现在,我的猜测是,当您添加.php扩展名时它可以工作,因为此方法实际上可以通过:

file_exists($_ci_path)

可能的操作是查看$ file_exists变量发生了什么,因为只有在发生这种情况时才将其设置为true:

if (file_exists($view_file.$_ci_file))

可能有帮助的其他信息

php.net上的file_exists方法也有一个有趣的注释:

file_exists will have trouble finding your file if the file permissions are not read enabled for 'other' when not owned by your php user. I thought I was having trouble with a directory name having a space in it (/users/andrew/Pictures/iPhoto Library/AlbumData.xml) but the reality was that there weren't read permissions on Pictures, iPhoto Library or AlbumData.xml. Once I fixed that, file_exists worked.

也许您可以在这些文件上发布权限,或尝试在那里浏览。

您也可以尝试在系统类中进行调试,以查找其中是否有任何错误。 这太奇怪了,因为我自己从未遇到过类似的事情,老实说,我看不到该库在其中有什么错位-它很可能与权限有关

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM