<?php
class Test{
public $test_1, $test_2;
}
$object = new Test();
$object->test_1 = "THIS IS A TEST";
$object->test_2 = "THIS IS A TEST 2";
$object->test_3 = "THIS IS A TEST 3";
var_dump($object);
如您所见,我没有名为 test_3 的变量。但我没有收到错误。它运行良好。为什么?这是我得到的输出。
object(Test)#1 (3) {
["test_1"]=>
string(14) "THIS IS A TEST"
["test_2"]=>
string(16) "THIS IS A TEST 2"
["test_3"]=>
string(16) "THIS IS A TEST 3"
}