主页
PHP
PHP foreach 循环
tryphp_foreach_object
运行 ❯
×
更改方向
保存代码
更改主题
<?php class Car { public $color; public $model; public function __construct($color, $model) { $this->color = $color; $this->model = $model; } } $myCar = new Car("red", "Volvo"); foreach ($myCar as $x => $y) { echo "$x: $y
"; } ?>
color: red
model: Volvo