2
這可能是一個非常愚蠢的問題的值:P但是我發現這真的interessting:實例化一個新類的字符串
class SomeClass{ var $var = "this is some text"; function echoVar($name){ echo $this->{$name}; } } $class = new SomeClass() $class->echoVar("var") // will echo "this is some text"
我可以做somethign相似的,我可以採取一個字符串的值並用這個名字實例化一個新類?如果不是,任何「幾乎」的解決方案?
謝謝