Skip to content

Instantly share code, notes, and snippets.

@sarices
Last active August 29, 2015 14:21
Show Gist options
  • Save sarices/c52ff7e6514f100cf52f to your computer and use it in GitHub Desktop.
Save sarices/c52ff7e6514f100cf52f to your computer and use it in GitHub Desktop.
自动路由到post或者get 的方法
use Think\Controller;
class TestController extends Controller {
protected function _empty(){
$act = '';
if(IS_POST) $act = 'post_';
if(IS_GET) $act = 'get_';
$method = $act.ACTION_NAME;
if(!method_exists($this,$method)) throw new \Exception('action not exists');
$this->$method();
}
private function test(){
//测试
}
private function post_test(){
//测试
}
private function get_test(){
//测试
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment