codeigniter测试

 

1.访问http://codeigniter.org.cn

下载CodeIgniter_2.0.3.zip

2.解压到 d:/htdocs/ci/

 

2.hosts设定

127.0.0.1 test.com

3.apache设定

<VirtualHost 127.0.0.1>

        ServerAdmin zzz_781111@sina.com

       DocumentRoot "d:/htdocs/ci/"

        ServerName test.com

</VirtualHost>

4.访问

http://test.com/

5.查看 D:\htdocs\CI\application\config\routes.php

可见默认访问页为

$route['default_controller'] = "welcome";

D:\htdocs\CI\application\controllers\welcome.php

6.所以访问

http://test.com/index.php/welcome/

http://test.com/index.php/welcome/index/

同样为首页

第一级参数welcome为控制器php脚本名,第二级参数index为脚本中的函数名

7.在

D:\htdocs\CI\application\controllers\welcome.php

加入函数

        function testnew(){

        echo "test new!";

}

访问

http://test.com/index.php/welcome/testnew/

9.

D:\htdocs\CI\application\controllers\welcome.php

加入函数

        function testnew2($a,$b,$c){

        echo "test new2 a=$a,b=$b,c=$c!";

}

访问

http://test.com/index.php/welcome/testnew2/1/2/3/

可见

 

第3级之后的参数都可以传入到对应函数中

10.

D:\htdocs\CI\application\controllers\welcome.php

加入函数

       function testpage()

       {

                $data = array('title' => '欢迎进入 http://codeigniter.org.cn',

                      'heading' => '欢迎',

                      'message' => 'http://codeigniter.org.cn');

        $this->load->view('testpage', $data);

       }

书写视图

D:\htdocs\CI\application\views\testpage.php

内容为

<html>

<head>

<title><?=$title?></title>

<head>

<body>

你好,<?=$heading?>进入<?=$message?>

</body>

</html>

11.

访问

http://test.com/index.php/welcome/testpage

12.windows去掉显示index.php

Apache 的Httpd.conf中

#LoadModule rewrite_module modules/mod_rewrite.so

打开

 

然后

<VirtualHost 127.0.0.1>

        ServerAdmin wenjie3@staff.sina.com.cn

       DocumentRoot "d:/htdocs/ci/"

        ServerName test.com

       RewriteEngine on

       RewriteCond $1 !^/(index\.php|images/|robots\.txt|js/|css/|img/)

       RewriteRule ^(.*)$ /index.php/$1 [L]

</VirtualHost>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值