java程序员学php -11.函数

public String join(String head, String body){
    if(body == null) body = "Nobody";
    return head + body;
}

function join(head, body='Nobody'){
    return head.body; 
}

区别:

  1.php的函数不会在方法签名中指定返回类型

  2.php的函数不会在方法签名中指定参数类型

  3.php的函数可以给参数设定默认值

Leave a Comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.