Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • What to you mean by variable $this mean in PHP?

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 103
    Comment on it

    Hello Reader's!

    If you have any doubt with the $this in PHP then you can see the example as below:-

    <?php
    class Person {
        public $name;
    
        function _&#95;construct( $name ) {
            $this->name = $name;
        }
    };
    
    $test= new Person('findnerd');
    echo $test->name;
    

    This stores the 'findnerd' string as a property of the object created. when you create a class you have (in many cases) instance variables and methods (aka. functions). $this accesses those instance variables so that your functions can take those variables and do what they need to do whatever you want with them.

 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: