What's the default inheritant type of a member function in PHP?
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.
精彩评论