WAMP Server的Code Igniter可以运行PHP应用程序 [英] Code Igniter with WAMP Server to run PHP application

查看:83
本文介绍了WAMP Server的Code Igniter可以运行PHP应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我一直无法在本地wamp服务器上运行静态.php页面.

这是根据代码点火器执行的步骤:
1.解压缩包.
2.将CodeIgniter文件夹和文件复制到我的本地服务器目录
3.进入代码点火器的应用程序文件夹(application/config/config.php),并使用记事本++将我的基本URL设置为http://cns_projects.com.

4.我在代码igniter文件夹中的application/controllers/pages.php上创建一个名为pages.php的文件,其代码如下:

Hi,

I have been unsuccessful with getting a static .php page to run on my local wamp server.

Here are my steps according to code igniter:
1. Unzip the package.
2. Copy the CodeIgniter folders and files to my local server directory
3. Go into the application folder of code igniter ( application/config/config.php)and set my base url to http://cns_projects.com using notepad++

4. I create a file named pages.php at application/controllers/pages.php in the code igniter folder with the following code

<?php
             class Pages extends CI_Controller {

    public function view($page = 'home')
    {
      if (!file_exists('application/views/pages/'.$page.'.php'))

         //Whoops, we don't have a page for that!
         show_404()

    }

      $data['title] = ucfirst($page); //Capitalize the first letter
      $this->load->view('templates/header', $data);
      $this->load->view('pages/'.$page, $data);
      $this->load->view('templates/footer', $data);

}



5.我使用以下代码在application/views/templates/header.php的代码igniter文件夹中创建一个header.php文件:



5. I create a header.php file in the code igniter folder at application/views/templates/header.php with following code:

<html>
<head>
	<title><?php echo $title ?> - CodeIgniter 2 Tutorial</title>
</head>
<body>
	<h1>CodeIgniter 2 Tutorial</h1>



6.在application/views/templates/footer.php
的代码igniter文件夹中的同一模板文件夹中创建页脚.



6. Create the footer in the same template folder located in the code igniter folder at application/views/templates/footer.php

© 2011	
</body>
</html>



7.我输入了我的网址:http://cns_projects.com/index.php/pages/view/,以查看我创建的名为home.php的页面.
我收到一条消息,指示禁止访问.错误403.


设置Code Igniter时我做错了什么,因此当我在视图中创建.php文件时,我能够输入URL进行访问.

任何帮助将非常感激.非常感谢.

Wayten



7. I entered in my web address: http://cns_projects.com/index.php/pages/view/ to see a page I created called home.php.
I got a message which says access is forbidden. Error 403.


What is I have done wrong in setting up Code Igniter so that when I create my .php file in the view I''m able to enter the url to access it.

Any help would be much appreciated. Thanks much.

Wayten

推荐答案

page = ' home') { 如果(!file_exists(' application/views/pages/'.
page = 'home') { if (!file_exists('application/views/pages/'.


页面.' .php')) // 糟糕,我们没有相应的页面! show_404() }
page.'.php')) //Whoops, we don't have a page for that! show_404() }


data [' title] = ucfirst(
data['title] = ucfirst(


这篇关于WAMP Server的Code Igniter可以运行PHP应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆