最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
zend历程 之 初认控制器
时间:2008-04-24 编辑:简简单单 来源:一聚教程网
今天要看的是控制器,这玩意太大,我也只是看看皮毛,由浅入深吧!
下面是一个简单的控制器:
class helloController extends Zend_Controller_Action
{
function indexAction()
{
echo "hi, this is my helloworld";
}
function testAction()
{
$var1 = $this->_getParam("var");
echo "hello".$book_id;
}
function __call($action,$args){
$this->_redirect(''/hello'');
}
}
运行结果是这样的:
http://localhost/hello/test/var/world 会显示 hellowrold
http://localhost/hello/netaction 时,会显示 hi, this is my helloworld
其实我想说明的也就上面分色的两点:
红:在Zend中,我有接收参数,不管是 post 还是 get 的,只要用 如:
$this->_getParam("var");
的形式即可,
final protected function _getParam($paramName, $default = null) 是控制器的私有方法,它还要可是带第二个参数,作为默认值,当没有得到你想要的参数时,返回这个默认值。
蓝:这个函数的目的为是,当访问的方法不存在时,自己转到一个地址(这里就是:http://localhost/hello 了)
-
上一个: zend历程 之 多模块控制器
相关文章
- zend历程 之 ZendFramework-1.0.3 04-24
- Zend Framework入门指引 04-24
- ZendCache使你的站点飞起来 03-13
- Zend引擎的发展 03-10
- Zend Studio 3.0试用手记 01-12
- PHP导出数据超时的优化建议解读 10-31