调用现有全局

时间:2015-05-07 14:03:21

标签: php variables memory global

在函数中调用现有的全局是否有记忆效应?

$someclass = new SomeClass();
$someclass->otherclass = new OtherClass();

function foo() {
    global $someclass;
    $someclass->otherclass->do_stuff();
}

VS

$someclass = new SomeClass();
$someclass->otherclass = new OtherClass();

function foo() {
    $otherclass = new OtherClass();
    $otherclass->do_stuff();
}

0 个答案:

没有答案