libweibo
libweibo copied to clipboard
调整 saetv2.ex.class.php 类 function getAccessToken 方法(函数)默认参数的不正确用法
函数默认参数的不正确用法
function getAccessToken($type = 'code',$keys)
{
return "Making a bowl of $type $keys.\n";
}
echo getAccessToken("raspberry"); // won't work as expected
以上例程会输出
Warning: Missing argument 2 in call to makeyogurt() in
/usr/local/etc/httpd/htdocs/phptest/functest.html on line 41
Making a bowl of raspberry .
函数默认参数正确的用法
function getAccessToken($keys,$type = 'code' )
{
return "Making a bowl of $type $keys.\n";
}
echo getAccessToken("raspberry"); // works as expected
PHP官方文档
?