以下是一个简单的PHP类实例,我们将创建一个名为`Car`的类,该类将包含一些基本属性和方法。

```php

实例php } 类,PHP实例:如何创建和使用类  第1张

class Car {

// 属性

public $brand;

public $model;

public $year;

// 构造函数

public function __construct($brand, $model, $year) {

$this->brand = $brand;

$this->model = $model;

$this->year = $year;

}

// 方法

public function displayInfo() {

echo "