Friday, November 20, 2009

How to Referencing an instance

In PHP 5 objects are passed by reference by default.

class Person{
function say_hello(){
echo "Say hello from inside a clas";
}
function say_hi(){
echo "Say hi";
}
}

$person=new Person();
$person2=new Person();

echo get_class($person)."
";
if(is_a($person2,'Person')){
echo "yes, Its a person";
}
else{
echo "No, Its not a person";
}
$person2->say_hello();
?>

No comments:

Post a Comment

I just got my #domain @BigRock. Get upto 25% off with my personalized coupon link Get upto 25% off