PHP - Classes and Objects
What will be the output of this PHP code?
class Animal {
public $type = "Cat";
}
$pet = new Animal();
echo $pet->type;class Animal {
public $type = "Cat";
}
$pet = new Animal();
echo $pet->type;Animal has a public property type set to "Cat". Creating an object $pet and accessing $pet->type returns "Cat".$pet->type prints "Cat".15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions