{ echo $type . " Թռավ " . $this->wingLenght . " մետրանոց թեվերով<br>"; } } class MarinAnimal extends Animal { public $volume; public function swim() { echo $type . " Լողաց"; } } /* $dog = new Animal("Շուն",25); echo "<pre>"; var_dump($dog); echo "</pre>"; $dog->breath(); $dog->eath(); */ $kalibri = new Bird("Կալիբլի", 25); $kalibri->wingLenght = 0.25; $kalibri->breath(); $kalibri->eath(); $kalibri->fly(); $dolpin = new MarinAnimal("Դելֆին", 10); $dolpin->volume = 1000; $dolpin->breath(); $dolpin->eath(); $dolpin->swim();
//store the object in a PHP variable $myObject = new MyClass(); </code></pre> <h4>OOP Basics: Using an Object</h4> <p>After an object is instantiated, you have access to any of its public behaviors or properties using the <code>-></code> operator.</p> <pre><code>//instantiate an object from the class $myObject = new MyClass(); //run the doSomething() function // using the -> operator $myObject->doSomething(); </code></pre> <span> <?php //define a class class Bird { function fly() { echo "<p>Flap flap!</p>"; } } //instantiate an object echo "<h3>Instantiate a new Object</h3>"; $aBird = new Bird(); //run an object's public function echo "<h3>Run a function</h3>"; $aBird->fly(); ?> </span> </body> </html>