<?php class TestClass1 { public $normal_v = 'normal_v from TestClass1'; public static $STATIC_V = 'STATIC_V from TestClass1'; public function test_func1() { echo $this->normal_v.'<br />'.self::$STATIC_V; } } class TestClass2 { public $normal_v = 'normal_v from TestClass2'; public static $STATIC_V = 'STATIC_V from TestClass2'; public function test_func2() { TestClass1::test_func1(); } } $t2 = new TestClass2(); $t2->test_func2(); 這段代碼是輸出會是什么呢,我原以為會是normal_v from TestClass1 <br /> STATIC_V from TestClass1,測試發現其實我錯了,正確的輸出是: normal_v from TestClass2 STATIC_V from TestClass1 說明:test_func1()雖然是在TestClass1中定義的,但卻是在TestClass2中調用的,其內部的$this變量則是由TestClass2決定的! 其實這兩個類的關系應該屬于"雙向關聯". 感興趣的朋友可以測試運行本文實例,相信會有新的收獲!