开发者

What's the default inheritant type of a member function in PHP?

开发者 https://www.devze.com 2022-12-20 13:24 出处:网络
class f开发者_如何学编程oo implements Countable { function count() { # do stuff here } } What\'s the type of count,public,protect or private?
class f开发者_如何学编程oo implements Countable {

    function count() {
        # do stuff here
    }
}

What's the type of count,public,protect or private?


Class methods may be defined as public, private, or protected. Methods declared without any explicit visibility keyword are defined as public.

Same behaviors also apply for class properties.

Taken from PHP: Visibility

As Bart has noted in his comment, although PHP will assign the visibility for you (if one is not explicitly assigned), it is strongly recommended for good practice and coding standards to assign the visibility for yourself.


It's type is public. In php if you don't specify scope for methods, it is assumed public.


Public....unless specified otherwise.

0

精彩评论

暂无评论...
验证码 换一张
取 消