class CityAction extends Action{ //前置操作方法 public function _before_index(){ echo ‘before<br/>‘; } public function index(){ echo ‘index<br/>‘; } //后置操作方法 public function _after_index(){ echo ‘after<br/>‘; } }
http://serverName/index.php/City/index
before index after
对于任何操作方法我们都可以按照这样的规则来定义前置和后置方法。如果当前的操作并没有定义操作方法,
原文:http://www.cnblogs.com/KTblog/p/5180311.html