If you omit the visibility keyword in your method declaration, by default the method will be declared as.
Correct answer
A. public
11 views
A. public
11 views
If no visibility keyword is given, a PHP method is public by default, meaning it can be called from anywhere the object is accessible.
This default exists for backward compatibility with PHP 4, which had no visibility control. Modern coding standards such as PSR-12 still require visibility to be written out explicitly on every method and property.
Want more practice? Try the full set of Computer Science MCQs on MCQsExam.com.
Not sure why the answer is A? Ask here and get an explanation.