yinzhili
发表于 2009-7-1 17:26:05
本帖最后由 yinzhili 于 2009-7-1 17:34 编辑
我简单点说吧。
假设你的Web根目录是 E:\AppServ\www\ ,请在这下边创建一个文件夹,命名为myci
将你下载到的CI源文件CodeIgniter_1.7.1.zip解压缩,目录结构应该是这样的:
system
user_guide
index.php
license.txt
你把这些文件及目录都复制到myci文件夹下(user_guide这个文件夹可以删掉),然后打开 E:\AppServ\www\myci\system\application\config\config.php 这个文件:
$config['base_url'] = "http://localhost/myci/";
这时候访问http://localhost/myci/,你应该可以看到一个"Welcome to CodeIgniter"页面,这就说明CI已经安装成功了。你要写的Blog控制器应该放在 E:\AppServ\www\myci\system\application\controllers 路径下,然后通过
http://localhost/myci/blog
来访问。例如说这样:
<?php
class Blog extends Controller{
function Blog(){
parent::Controller();
}
function index(){
$this->load->view('blog');
}
}
?>
这段代码保存到E:\AppServ\www\myci\system\application\controllers 路径下,命名为blog.php。(文件名和大小写都很重要)
atxlin
发表于 2009-7-2 09:53:44
感谢楼上对小弟这样的新手提供这样的帮助。
我访问http://localhost/myci/ 跳出一个欢迎页面
E:\AppServ\www\myci\system\application\controllers 路径下建立了一个blog.php页面
<?php
class Blog extends Controller{
function Blog(){
parent::Controller();
}
function index(){
echo "Hello World";
}
}
?>
访问http://localhost/myci/blog时浏览器说没找到这个页面
atxlin
发表于 2009-7-2 09:56:17
问题解决了一定要用http://localhost/myci/index.php/blog才能访问吗???为什么要加index.php
Hex
发表于 2009-7-2 10:17:22
问题解决了一定要用http://localhost/myci/index.php/blog才能访问吗???为什么要加index.php
atxlin 发表于 2009-7-2 09:56 http://codeigniter.org.cn/forums/images/common/back.gif
为什么不加 index.php 呢?没有 index.php PHP 怎么知道谁处理你的请求呢?
想去掉要使用 URL Rewrite。。。 参考 http://codeigniter.org.cn/forums/thread-4-1-3.html
atxlin
发表于 2009-7-2 10:21:19
感谢管理员,我现在正在看文档,写的很详细很好。
huapiaoxiang
发表于 2009-7-6 17:51:12
<php
class Blog extends Controller{
function index()
{
$this->load->view("blog_view");
}
}
?>
如果你的视图在文件夹下面,那么加载的时候得加上文件夹名.
<?php
class Blog extends Controller{
function index()
{
$this->load->view("Blog/blog_view");
}
}
?>