Inline class definition no loading required

suggest change
// zoo.php
class Animal {
    public function eats($food) {
        echo "Yum, $food!";
    }
}

$animal = new Animal();
$animal->eats('meat');

PHP knows what Animal is before executing new Animal, because PHP reads source files top-to-bottom. But what if we wanted to create new Animals in many places, not just in the source file where it’s defined? To do that, we need to load the class definition.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Autoloading primer:
*Inline class definition no loading required

Table Of Contents
5Autoloading primer
19XML
81PDO
102APCu
108PSR