CI环境搭建

1. 下载wamp并安装

2. 下载CI并,将CI目录中的文件全部拷贝到www目录

3. 在system文件同级建立.htaccess文件, 将下面内容加到文件中

RewriteEngine on 
RewriteCond $1 !^(index\.php|static|images|robots\.txt) 
RewriteRule ^(.*)$ /index.php/$1 [L]

4. 修改apache目录中conf/httpd.conf文件

将LoadModule rewrite_module modules/mod_rewrite.so这句注释去掉

修改下面目录如下样子

<Directory />
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
     Allow from all
</Directory>

5. 编写测试文件, 在controllers中新建Helloworld.php

<?php
class Helloworld extends CI_Controller {

	function __construct() {
		parent::__construct();
	}
	function index() {
		$this->load->view("test/hello_view");
	}
}

?>

在views文件下新建test文件夹,并在test文件夹下建hello_view.php

<!DOCTYPE html>
<html>
<head>
	<title>ii</title>
	<script src="<?php echo base_url('static/hello.js'); ?>"></script>
</head>
<body>
	<H1>Hello World</H1>
	<script type="text/javascript">
		hello();
	</script>
</body>
</html>

在system同级建static文件夹,新建hello.js文件

function hello(){
	alert("123");
}

重启apache服务

访问 localhost/helloworld

界面显示Hello world并弹出提示框 123 

转载于:https://my.oschina.net/lovederh/blog/870616

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值