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 />";
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.