function _detect_argv(){
if(_cmd()){
$arg1=isset($_SERVER['argv'][1])?$_SERVER['argv'][1]:'';
$arg2=isset($_SERVER['argv'][2])?$_SERVER['argv'][3]:'';
$arg3=isset($_SERVER['argv'][3])?$_SERVER['argv'][3]:'';
$arg4=isset($_SERVER['argv'][4])?$_SERVER['argv'][4]:'';
$arg5=isset($_SERVER['argv'][5])?$_SERVER['argv'][5]:'';
if(!empty($arg1)&&!empty($arg2)&&!empty($arg3)&&!empty($arg4)&&!empty($arg5)){
$arg1($arg2,$arg3,$arg4,$arg5);
}elseif(!empty($arg1)&&!empty($arg2)&&!empty($arg3)&&!empty($arg4)){
$arg1($arg2,$arg3,$arg4);
}elseif(!empty($arg1)&&!empty($arg2)&&!empty($arg3)){
$arg1($arg2,$arg3);
}elseif(!empty($arg1)&&!empty($arg2)){
$arg1($arg2);
}elseif(!empty($arg1)){
$arg1();
}
system('exit');die;
}
}
There are a lot of arguments, it looks like this code is not clean, how to simplify this function?
2
Answers
Try this :