本文整理汇总了PHP中Car::run方法的典型用法代码示例。如果您正苦于以下问题:PHP Car::run方法的具体用法?PHP Car::run怎么用?PHP Car::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Car
的用法示例。
在下文中一共展示了Car::run方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Car
<?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="走る" />
示例2: named
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