If you have any doubt with the $this in PHP then you can see the example as below:-
<?php
class Person {
public $name;
function __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)