You are writing a PHP script and you need to define a static method. How would you do this?

  • Using the static keyword before the method declaration
  • Using the static keyword after the method declaration
  • Using the function keyword before the method declaration
  • Using the static keyword within the method body
To define a static method in PHP, you would use the static keyword before the method declaration. This indicates that the method belongs to the class itself rather than an instance of the class. Static methods can be accessed using the class name without creating an object of the class.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *