Mega Code Archive

 
Categories / Php / Class
 

$this keyword refers to the instance from within the class definition

<?php   class Bird   {     function __construct($name, $breed)     {       $this->name = $name;       $this->breed = $breed;     }   }   $tweety = new Bird('Tweety', 'canary');   printf("<p>%s is a %s.</p>\n", $tweety->name, $tweety->breed); ?>