Home>Article>Backend Development> What to do if the php object parameters are not sure
When the php object parameters are uncertain, you need to change the writing method. The modified code is such as "function uncertainParam() {$args = func_get_args();foreach($args as $key=>$value){ ...}}".
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
What should I do if the php object parameters are not sure?
php indefinite parameter method (function) and optional parameter method (function)
Methods are often used when writing code, and they are often methods with parameters. These It is all familiar to us, but sometimes the number of method parameters that need to be used is uncertain, so we need to change the writing method, as follows:
$value){ echo '
'.func_get_arg($key); //获取单个参数的值 echo '
'.$value; //单个参数的值 } var_export($args); } $parm_fir = 'name'; $parm_sec = 'sex'; uncertainParam($parm_fir, $parm_sec);
Optional parameters:
Recommended learning: "PHP video tutorial"
The above is the detailed content of What to do if the php object parameters are not sure. For more information, please follow other related articles on the PHP Chinese website!