$value){...}}"."/> $value){...}}".">

Home>Article>Backend Development> What to do if the php object parameters are not sure

What to do if the php object parameters are not sure

藏色散人
藏色散人 Original
2022-01-14 09:11:41 1624browse

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){ ...}}".

What to do if the php object parameters are not sure

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn