Question

class foo implements Countable {

    function count() {
        # do stuff here
    }
}

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

Was it helpful?

Solution

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.

OTHER TIPS

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

Public....unless specified otherwise.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top