1.可以使用func_get_args()和func_num_args()这两个函数实现函数的重载!!
PHP代码:
function rewrite() {
$args = func_get_args();
if(func_num_args() == 1) {
func1($args[0]);
} else if(func_num_args() == 2) {
func2($args[0], $args[1]);
}
}
function func1($arg) {
echo $arg;
}
function func2($arg1, $arg2) {
echo $arg1, ' ', $arg2;
}
rewrite('PHP'); //调用func1
rewrite('PHP','China'); //调用func2
2.使用默认值,从而根据输入,得到自己想要的结果:
本文和大家重点讨论一下Perl性能优化技巧,利用Perl开发一些服务应用时,有时会遇到Perl性能或资源占用的问题,可以巧用require装载模块,使用系统函数及XS化模块,自写低开销模块等来优化Perl性能。 Perl是强大的语言,是强大的工具,也是一道非常有味道的菜:-)利用很多perl的特性,可以实现一些非常有趣而实用的功能。希望本文档会给有需要的朋友带来帮助;感兴趣的朋友可以过来看看
function test($name="小李",$age="23"){
echo $name." ".$age;
}
test();
echo "
";
test("a");
echo "
";
test("a","b");










