以下是一个简单的PHP实例,用于展示如何封装类和方法。
类的创建
我们需要创建一个类,这个类将包含一些方法和属性。

```php
class Car {
// 属性
public $color;
public $brand;
// 构造方法
public function __construct($color, $brand) {
$this->color = $color;
$this->brand = $brand;
}
// 方法
public function drive() {
return "







