Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Static method in PHP

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 132
    Comment on it

    When we declare a function as static then we generally get confused about what to use like '->', '::', 'this' or 'self'. There are something we need to take care of when declaring a function as static:

    1: If the variable or method being referenced is declared as const or static, then you must use the :: operator.

    2: If the variable or method being referenced is not declared as const or static, then you must use the -> operator.

    3: If you are accessing a const or static variable or method from within a class, then you must use the self-reference self.

    4: If you are accessing a variable or method from within a class that is not const or static, then you must use the self-referencing variable $this.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: