-1

Consider i'm big newbe in php, so.. I made a function with some arguments who do something, and i want to call only one argument.. Here is my test:

   public static function test($arg1,$arg2,$arg3)
    {

   $bob1 = "thats arg1";
   $bob2 = "thats arg2";
   $bob3 = "thats arg3";

   $arg1 = echo $bob1;
   $arg2 = echo $bob2;
   $arg3 = echo $bob3;

    }

Now I want to call just $arg3, how can I call test($arg3);? Is it "legal" to do test(' ' , ' ' , $arg3 ), or is there a better practice?

4

1 回答 1

1
 public static function test($arg1='',$arg2='',$arg3='')
{
 if(!empty($arg1)){
  echo $arg1;
  }
  elseif(!empty($arg2)){
  echo $arg2;
  }
  elseif(!empty($arg3)){
  echo $arg3;
  }
  else{ echo 'no argu'; }

}

我认为你的意思是 echo test('','',$arg3);

于 2013-10-31T11:55:16.047 回答