本文整理汇总了PHP中Vehicle::toString方法的典型用法代码示例。如果您正苦于以下问题:PHP Vehicle::toString方法的具体用法?PHP Vehicle::toString怎么用?PHP Vehicle::toString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vehicle
的用法示例。
在下文中一共展示了Vehicle::toString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setPrice
*
* @param float $price
*/
protected function setPrice($price)
{
if (is_float($price) || is_int($price)) {
$this->price = (double) $price;
} else {
throw new Exception($this->getModel() . "'s price must be a numeric value!");
}
}
}
//Creating new Vehicle objects
try {
$car = new Vehicle("Chevy", "Colorado", "2015", 20120);
echo $car->toString() . "<br />";
//Commenting out the code that will flag an error.
//$car2 = new Vehicle("Chevy", "Silverado", "2015", "4900o"); //has an OH instead of zero
//echo $car2->toString() . "<br />";
} catch (Exception $ex) {
echo "Error, " . $ex->getMessage() . "<br />";
}
?>
</p>
</div>
<div>
<h1>
8. Consider the following array:
</h1>
<code>