}
$ov = new CallOverload();
$ov->display(array(1, 2, 3));
$ov->display('cat');
// ----------------------------------------------
//  __autoload() -
// ----------------------------------------------
// can be used to load a class which is not yet declared
function __autoload($name)
{
    echo "Loading " . $name . ".php";
    include_once $name . ".php";
}
$autoloadClass = new AutoLoadClass();
echo " Math::pi = " . Math::pi . "\n";
echo " Math::squared(8) = " . Math::squared(8) . "\n";
// ----------------------------------------------
//  Iterator and IteratorAggregate
// ----------------------------------------------
// can be thought of Enumerable and Enumerator
// check the Iterator.php for details
// ----------------------------------------------
//  __toString() function
// ----------------------------------------------
// how a class be stringized
class Printable
{
    public $testone;
    public $testtwo;
    public function __toString()
    {
Example #2
0
 * Created by PhpStorm.
 * User: zzy
 * Date: 2015/11/30
 * Time: 21:25
 */
class Math
{
    const pi = 3.14159;
    static function squared($input)
    {
        return $input * $input;
    }
}
echo "<h1>Per-Class常量、静态方法</h1>";
echo " Math::pi = " . Math::pi . "\n";
echo " Math::squared(8) -> " . Math::squared(8) . "\n";
interface Displayable
{
    function display();
}
class webPage implements Displayable
{
    function display()
    {
        echo "这个类实现了接口Displayable<br/>";
    }
}
class animation implements Displayable
{
    function display()
    {