Class Type Hints

<?
    class Dog {
            public function do_drool( ) {
                    echo "Sluuuuurp\n";
            }
    }    class Cat { }    function drool(Dog $some_dog) {
            $some_dog->do_drool( );
    }
    $poppy = new Dog( );
    drool($poppy);
 
    $poppy = new Cat( );
    drool($poppy);
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.