以下是一个简单的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 "