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