我有这个类,我想从Gettest
方法中获得第二个方法runSecond
中的值。我会怎么做?如何访问方法的变量
class Test {
public static function Gettest($x, $y, $z){
$x = $x;
$x = $x . basename($y);
self::runSecond();
}
private function runSecond(){
//how do I access $x here? I need to know the value of $x, $y and $z here
// and I dont want to pass it like this self::runSecond($x, $y, $z)
}
}
说真的。别。停止。问问你自己想要什么。然后做一个理智的方式。 (我会建议只将值传递给'runSecond',而是一个类*成员变量* - 参见[类和对象](http://php.net/manual/en/language.oop5.php) - 是另一种可能适用的方法 - 但在这个有限的上下文中看起来令人怀疑。) – 2010-11-10 18:52:29
我想学习如何访问类memeber变量? – Autolycus 2010-11-10 18:53:33
可能重复[访问变量从另一个函数的作用域?](http://stackoverflow.com/questions/1699117/access-variable-from-scope-of-another-function) – outis 2012-02-13 12:50:59