Mega Code Archive

 
Categories / Php / Class
 

Accessing the $age variable using this-

<?php class Cat {     var $age;     function Cat($new_age){         $this->age = $new_age;     }     function Birthday(  ){         $this->age++;     } } $fluffy = new Cat(1); echo "Age is $fluffy->age <br />"; echo "Birthday<br/>"; $fluffy->Birthday(  ); echo "Age is $fluffy->age <br />"; ?>