使用PHP,当我调用类的实例时,我会收到一个未定义的变量通知.我用其他语言编程,但不太熟悉PHP,你能不能看看我的代码并告诉我在定义类变量时的错误?谢谢.
<?php
// create class Bike
class Bike
{
// create variables for class Bike of price, max_speed, and miles
var $price;
var $max_speed;
var $miles;
// create constructor for class Bike with user set price and max_speed
function __construct($price, $max_speed)
{
$this->price = $price;
$this->max_speed = $max_speed;
}
// METHODS for class Bike:
// displayInfo() - have this method display the bike's price, maximum speed, and the total miles driven
function displayInfo()
{
echo "Price: $" . $price . …Run Code Online (Sandbox Code Playgroud)