yakczh
V2EX  ›  PHP

slim 里面 get/post 请求分开处理有什么好处?

  •  
  •   yakczh · Jul 1, 2015 · 2846 views
    This topic created in 4011 days ago, the information mentioned may be changed or developed.

    比如

    $app->get('/hello/:name', function ($name) {
    echo "Hello, $name";
    });

    $app->post('/hello/:name', function ($name) {
    echo "Hello, $name";
    });

    相比传统的 class xxController {

    function xxxAction($name){
        echo "hello".$name
      }
    

    }
    有什么好处吗?

    ywisax
        1
    ywisax  
       Jul 1, 2015
    可以提高灵活度。
    如果不想这样折腾,那就用map(.........)->via('GET', 'POST')来做吧
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   919 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 21:48 · PVG 05:48 · LAX 14:48 · JFK 17:48
    ♥ Do have faith in what you're doing.