Home  >  Article  >  Backend Development  >  zend framework怎么实现像 微博一样的 action

zend framework怎么实现像 微博一样的 action

WBOY
WBOYOriginal
2016-06-13 13:43:55670browse

zend framework如何实现像 微博一样的 action?
zend framework如何实现像 微博一样的 action?

比如腾讯微博的 t.qq.com/ yourname 

这个 yourname 是存放在数据库用户表中的 username一列。 那么zend framework如何实现这个功能呢。

像其它静态的action都是可以直接写好 controllers.但是动态的我就不懂了。

我是个初学者,很多不懂。知者望能详细指点。。用纯粹的php也行,但别用别的框架,我研究zf蛋都碎了。不想再又去搞另一个框架。

谢谢。。

------解决方案--------------------
zend有router,看这里即可

http://framework.zend.com/manual/1.11/en/zend.controller.router.html
------解决方案--------------------

../public/index.php部分代码如下 

$ctrl = Zend_Controller_Front::getInstance();
$router = $ctrl->getRouter();
//:username 是变量 ,module->设置模块
$route = new Zend_Controller_Router_Route ( ':username', array ('module'=>'rout','controller' => 'index', 'action' => 'info' ) );
$router->addRoute ( 'user', $route );

rout 模块下 IndexController.php 部分代码

public function infoAction() {
$username = $this->_getParam('username');
print_r($username);
exit ();
}

呵呵 结贴吧,这样就可以实现了,楼主还有什么问题 可以随时沟通 呵呵

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn