PHP - Classes and Objects
Find the error in this code snippet:
class Animal {
public $type;
}
$a = new Animal;
echo $a->type;Find the error in this code snippet:
class Animal {
public $type;
}
$a = new Animal;
echo $a->type;$a = new Animal; is valid in PHP; parentheses are optional if no constructor arguments.type is declared but not set, so echoing it outputs nothing or null.type is not initialized before use. -> Option D15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions