我在
之后创建了zend结构 -test
-application
-controllers
-modules
-views
-filters
-helpers
-scripts
-index
-user
-library
+zend //zend file or modules
-web_root
-css
-img
-js
.htaccess
index.php
中的代码./test/web_root/
的.htaccess
RewriteEngine On
RewriteRule .* index.php
和 index.php 代码是
<?php
error_reporting(E_ALL|E_STRICT);
ini_set('display_errors', true);
date_default_timezone_set('Europe/London');
$rootDir = dirname(dirname(__FILE__));
set_include_path($rootDir . '/library' . PATH_SEPARATOR . get_include_path());
require_once 'Zend/Controller/Front.php';
Zend_Controller_Front::run('../application/controllers');
?>
./test/application/controllers中的代码
IndexController.php 代码
<?php
require_once 'Zend/Controller/Action.php';
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
$this->view->assign('title', 'Hello, World!');
$this->view->assign('wellcome','Wellcome to my site.');
$this->view->assign('webmaster','Wiwit');
}
}
?>
和 UserController.php
<?php
require_once 'Zend/Controller/Action.php';
class UserController extends Zend_Controller_Action
{
public function indexAction()
{
$this->view->assign('name', 'Wiwit');
$this->view->assign('title', 'Hello');
}
public function nameAction()
{
$this->view->assign('name', 'Wiwit');
$this->view->assign('title', 'User Name');
}
}
&GT;
代码在./test/application/views/scripts/index
中index.phtml
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhmtl">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title><?php echo $this->escape($this->title); ?></title>
</head>
<body>
<h1><?php echo $this->escape($this->title); ?></h1>
<?=$this->escape($this->wellcome);?>
<p> </p>
<?=$this->escape($this->webmaster);?>
</body>
</html>
代码在./test/application/views/scripts/user 中
index.phtml
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><? echo $this->escape($this->title); ?></title>
</head>
<body>
<h1><?=$this->escape($this->title);?>, <?=$this->escape($this->name);?></h1>
</body>
</html>
未找到类似问题网址
localhost/test/web_root/user