Which of the following is/are the right way to declare a method?
i) function functionName() { function body }
ii) scope function functionName() { function body }
iii) method methodName() { method body }
iv) scope method methodName() { method body }
a) Only ii)
b) Only iv)
c) i) and ii)
d) iii) and iv)
Answer: c
Explanation: In case of public methods, you can forgo explicitly declaring the scope and just declare the method like you would a function.
Related Posts
Which of the following method scopes is/are not supported by PHP?
i) private
ii) friendly
iii) static
iv) abstractWhich one of the following is the right way to invoke a method?
Which one of the following is the right way to call a class constant, given that the class is mathFunction?
Which one of the following is the right way to define a constant?
Which one of the following can be used to instantiate an object in PHP assuming class name to be Foo?
Which one of the following property scopes is not supported by PHP?
The practice of creating objects based on predefined classes is often referred to as ______________
Join The Discussion