【发布时间】:2013-04-12 12:48:53
【问题描述】:
我已经安装了 CodeIgniter_2.1.3 并在
中运行- Windows 7
- Wamp 服务器 2.1
- PHP 5.3.5
- Apache 2.2.17
我关注了 Codeignitor 中提供的 Codeignitor Static Pages Tutorial 链接。
我在 application/controllers/pages.php 中创建了文件,其中包含以下代码。
<?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);
}
}
?>
然后我在 application/views/templates/header.php 创建了标题,代码如下:
<html>
<head>
<title><?php echo $title ?> - CodeIgniter 2 Tutorial</title>
</head>
<body>
<h1>CodeIgniter 2 Tutorial</h1>
然后我使用以下代码在 application/views/templates/footer.php 创建了一个页脚:
<strong>© 2011</strong>
</body>
</html>
然后当我打电话给http://localhost/CodeIgniter_2.1.3/index.php/pages/view/home
我得到了这个作为输出
欢迎使用 CodeIgniter!
您正在查看的页面是由 CodeIgniter。
如果您想编辑此页面,您可以在以下位置找到它: 应用程序/views/welcome_message.php
此页面对应的控制器位于: 应用程序/控制器/welcome.php
如果您是第一次探索 CodeIgniter,您应该 首先阅读用户指南。
而不是获取带有附加 header.php 和 footer.php 的 home.php。
我怀疑这是因为 codeignitor 配置或 php 配置或 apache 服务器配置中的一些错误设置。
【问题讨论】:
-
你为什么不尝试去
http://localhost/CodeIgniter_2.1.3/index.php -
谢谢。我现在可以输入每个页面。我只是将 base_uel 设置为空白。我将 index_page 设置为 index.php。我现在使用 codeigniter 表单函数。
标签: php codeigniter apache2