Esempio n. 1
0
<?php

require 'taxiClass.php';
$yellow_taxi = new Car();
if (isset($_REQUEST['action'])) {
    $action = $_REQUEST['action'];
    switch ($action) {
        case 'engine':
            $yellow_taxi->start();
            break;
        case 'run':
            $yellow_taxi->run();
            break;
        case 'stop':
            $yellow_taxi->stop();
            break;
        default:
            # code...
            break;
    }
}
?>


<html>
<body>
	<form method="post" action="taxi_demo.php?action=engine">
		<input type="submit" value="エンジンを掛ける" />
	</form>
	<form method="post" action="taxi_demo.php?action=run">
		<input type="submit" value="走る" />
explicitly named (usually the one on the left of the :: operator); in case
of non static method calls, it is the class of the object.

A "forwarding call" is a static one that is introduced by self::, parent::,
static::, or, if going up in the class hierarchy, forward_static_call().

The function get_called_class() can be used to retrieve a string with the name
of the called class and static:: introduces its scope. 
*/
class Car
{
    public static function run()
    {
        return static::getName();
    }
    private static function getName()
    {
        return 'Car';
    }
}
class Toyota extends Car
{
    public static function getName()
    {
        return 'Toyota';
    }
}
echo Car::run();
// output: Car
echo Toyota::run();
// output: Toyota