-6
class blah{

    function a( x ){
    $variablename = b();
    ....
    }

    function b(){
    echo("why is this code (first line of function b) seemingly unreachable");
    ....
    }
}

在本地服务器上执行时它工作正常,但不是!

4

3 回答 3

2
$variable = $this->b();

如果您从非静态上下文中调用它。否则

$variable = self::b();
于 2012-11-13T11:49:47.777 回答
1

您在所有变量上都缺少美元符号 ($)。

我真的很惊讶它在本地工作。

于 2012-11-13T11:49:45.640 回答
0

试试这个:

class blah{
    function a( $x ){
        $this->b(); // <---- added this ...
    }

    public function b(){
        echo("why is this code (first line of function b) seemingly unreachable");
    }

}

$test = new blah;
$test->a("some_string");
于 2012-11-13T11:54:00.873 回答