libweibo icon indicating copy to clipboard operation
libweibo copied to clipboard

调整 saetv2.ex.class.php 类 function getAccessToken 方法(函数)默认参数的不正确用法

Open Tinywan opened this issue 7 years ago • 1 comments

函数默认参数的不正确用法

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官方文档

Tinywan avatar Jan 11 '18 01:01 Tinywan

?

Tinywan avatar Jan 24 '18 00:01 Tinywan