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