php how to call many times of one function and get parameter

戏子无情 提交于 2019-12-11 14:35:35

问题


how laravel route get argument from caller function with same name

class Route{

    public $urlname;
    function __construct($geturl){
    //get url like this $this->url=$geturl["REQUEST_URI"];
}

function get($url,/*(description=closure or require controller and get methods, but now for test)*/ $test){

    if($url===$this->urlname){
        //i don't know what to do here for To get the argument I want
        echo $test;
    }

 }

 function post(){
        ///
 }


  $obj=new Route($_SERVER);

  $obj->get("url","index@index");
  $obj->get("url","hellodear");
  $obj->get("url","hisweety");
  $obj->get("url","poopelephant=php");
  //...

Output

index@indexhellodearhisweetypoopelephant=php

but i want output be like this

index@index
or
hellodear
or
hisweety

and also getting more arguments if the function has more arguments

/*function get($url,$test,...$morearg)*/

来源:https://stackoverflow.com/questions/58887225/php-how-to-call-many-times-of-one-function-and-get-parameter

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!