Last active
August 29, 2015 14:21
-
-
Save sarices/c52ff7e6514f100cf52f to your computer and use it in GitHub Desktop.
自动路由到post或者get 的方法
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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