What are static methods in PHP object oriented programming?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    What are static methods in PHP object oriented programming?

    You can make methods static which means you do not need to create an instance of the class in order to execute the method. For example:

    PHP Code:
    <?php
    class Output
    {
    public static function 
    output_text($text)
    {
    echo 
    $text;

    }

    // execute method

    Output::output_text("<p>Really important text!</p>");
    ?>
    The double colon is a scope resolution operator: PHP: Scope Resolution Operator (: - Manual - it allows access to static and overridden class-level variables (properties) and methods (overriding in regards to the use of inheritance in object oriented programming) and class constants.
Working...
X