Final Keyword

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • priya.sharma
    Senior Member
    • Aug 2016
    • 105

    Final Keyword

    What is the use of final keyword in PHP???
  • Guest

    #2
    PHP 5 introduces the final keyword, which prevents child cl***es from overriding a method by prefixing the definition with final. If the cl*** itself is being defined final then it cannot be extended.Properties cannot be declared final, only cl***es and methods may be declared as final.

    Comment

    • lisajohn
      Senior Member
      • May 2007
      • 218

      #3
      The final keyword prevents child cl***es from overriding a method or constant by prefixing the definition with final . If the cl*** itself is being defined final then it cannot be extended. Note: Properties cannot be declared final: only cl***es, methods, and constants (as of PHP 8.1).

      Comment

      • Guest

        #4
        The final keyword is a non-access modifier used for cl***es, attributes and methods, which makes them non-changeable (impossible to inherit or override). The final keyword is useful when you want a variable to always store the same value, like PI (3.14159...). The final keyword is called a "modifier".

        Comment

        Working...
        😀
        😂
        🥰
        😘
        🤢
        😎
        😞
        😡
        👍
        👎