1. You can use the two functions func_get_args() and func_num_args() to implement function overloading!!
PHP code:
Copy code The code is as follows:
function rewrite() {
$args = func_get_args();
if(func_num_args() == 1) {
func1($args[0]);
} else if(func_num_args() == 2) {
fun c2($args[0], $args [1]);
{
echo $arg1, ' ', $arg2;
}
rewrite('PHP'); //Call func1
rewrite('PHP','China'); //Call func2
2. Use the default value to get the results you want based on the input:
Copy code
The code is as follows:
function test($name="Xiao Li",$age="23") { echo $name." ".$age; } }
test();
echo "
";
test("a") ;
echo "
";
test("a","b");
http://www.bkjia.com/PHPjc/779164.htmlwww.bkjia.com
truehttp: //www.bkjia.com/PHPjc/779164.htmlTechArticle1. You can use the two functions func_get_args() and func_num_args() to implement function overloading!! PHP code : Copy the code as follows: function rewrite() { $args = func_get_args(); if(func_...