$this->fly();
        $this->sing();
    }
}
/*
 * instantiate the class
 * */
echo "<p>Create a new Bird Object...</p>";
$hummingbird = new Bird();
/*
try out the various functions
*/
echo "<p>Run sing() function...</p>";
$hummingbird->sing();
echo "<p>Run and echo getSong() function ...</p>";
echo $hummingbird->getSong();
echo "<p>Run setSong() to change the Brid's song...</p>";
$hummingbird->setSong("Caw caw!");
echo "<p>Run and echo the song to prove it has been changed...</p>";
echo $hummingbird->getSong();
echo "<p>Run demonstrateBirdness()...</p>";
$hummingbird->demonstrateBirdness();
echo "<p>Create another new Bird Object...</p>";
$eagle = new Bird();
$eagle->setSong("Screech!");
$eagle->demonstrateBirdness();
?>
	</span>
	<h3>Comparing Objects</h3>
   <p>The <strong>==</strong> comparison operator determines if two objects are different instances of the same class, and whose properties share the same values. The <strong>===</strong> comparison returns true only if the two objects being compared are instances of the same class. Use <a href="http://php.net/manual/en/function.get-class.php">get_class( )</a> to determine what class an object is.</p>	
   <span>
Ejemplo n.º 2
0
    public function getSong()
    {
        return $this->song;
    }
    //mutator (usually takes a parameter(s) and )
    public function setSong($newSong)
    {
        if (!is_string($newSong)) {
            echo "<p>'" . $newSong . "' is not a reasonable song. Song has not been changed</p>";
        }
        $this->song = $newSong;
    }
}
echo "<h3>Instantiate a new Object</h3>";
$aBird = new Bird();
echo "<h3>Run public functions</h3>";
echo "<p>Run accessor getSsong(): " . $aBird->getSong() . "</p>";
echo "<p>Run mutator setSong() to change the song...</p>";
$aBird->setSong("Tweet tweet!");
echo "<p>Run accessor getSong(): " . $aBird->getSong() . "</p>";
echo "<h3>Try to setSong() to something unreasonable (eg: a number)...</h3>";
$aBird->setSong(42);
echo "<h3>If a property is public, it can potentially be abused...</h3>";
echo "<p>Public \$birdType is currently: " . $aBird->birdType . "</p>";
echo "<p>Re-assigning the value of \$birdType</p>";
$aBird->birdType = "Cheeseburger";
echo "<p>Public \$birdType is currently: " . $aBird->birdType . "</p>";
?>
</span>
</body>
</html>