Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/codeigniter/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 控制器未执行:错误404_Php_Codeigniter - Fatal编程技术网

Php 控制器未执行:错误404

Php 控制器未执行:错误404,php,codeigniter,Php,Codeigniter,我使用CI v2.0.3、xampp windows 1.7.0,并将CI文件夹重命名为“Hello” 我在application/controller上创建了一个Blog.php Blog.php的内容是: <?php if(!defined('BASEPATH')) exit('No Direct Script Access Allowed'); class Blog extends CI_Controller { function __construct()

我使用CI v2.0.3、xampp windows 1.7.0,并将CI文件夹重命名为“Hello”
我在application/controller上创建了一个Blog.php

Blog.php的内容是:

<?php
if(!defined('BASEPATH')) exit('No Direct Script Access Allowed');

class Blog extends CI_Controller {
        function __construct()
        {
            parent::__construct();
        }

        function index()
        {
            echo "Haloo.. CI pertama";     
        }
}

您需要在索引操作中呈现视图

您的视图位于应用程序/视图中。因此,您必须创建一个名为
index.php
的文件,将
Hello World
放在其中。然后将此添加到函数中:

$this->load->view('index');

希望这能有所帮助。

如果您没有为Apache启用重写模块,则输入的URL不正确。对于考虑文件夹名称的设置,请尝试:

http://localhost:8080/Hello/index.php?/blog

编辑:添加的文件夹名称

如果您的CI文件夹名为“Hello”,则您可以按如下方式访问它:

http://localhost:8080/Hello/index.php/blog

干什么!文件夹名称区分大小写,因此
/hello/index.php/blog
将不起作用

如果(!!defined('BASEPATH'))这是一个打字错误吗?@radashk如果我与CI默认控制器示例进行比较,它似乎是一个typo.thx进行更正,但仍然找不到404。
404
错误看起来“华丽”还是相当丑陋?我这样问是因为我们首先需要确定CI是否被调用。也许这太明显了,但您确实将CI放置在XAMPP的htdocs目录中,对吗?在[xampp path]\htdocs\hello\index.php处使用index.php?它是Apache404还是CI?您可以访问本地主机吗?XAMPP是否显示了那里的Hello文件夹?是否更改了/config/config.php中的任何内容?还是一个.htaccess文件?@radask是的,我可以访问xampp主页,有phpadmin、phpinfo等菜单,不是吗?我不会从config.php更改任何配置。。我只是将apache端口更改为8080,因为端口80与我的SQL Server服务冲突…仍然相同,找不到404页。。它和港口有关系吗?还是htaccess?我没有修改任何东西。我用最新版本重新安装xampp,使用最新的CI,并在我的windows 7上破坏UAC,解决了问题。真的,仍然没有找到404php。。你能告诉我这是什么样的问题吗?你能分享CodeIgniter的物理路径吗?这有点令人沮丧,因为我两天前就有这个问题,我的笔记本电脑有什么问题吗?@adadeh我不认为你的设置有什么问题,这一定是一个非常愚蠢的错误,我们都找不到他。去看看,也许你会发现。。。