以下是一个简单的PHP面向对象编程(OOP)实例,我们将创建一个`Car`类,并展示如何使用这个类来创建对象和调用方法。
实例:创建一个Car类
```php

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 "







