Skip to content

Conversation

@Tinywan
Copy link

@Tinywan Tinywan commented Jan 11, 2018

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

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
Copy link
Author

Tinywan commented Jan 24, 2018

?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant