What does =& mean in PHP?

前端 未结 3 1157
半阙折子戏
半阙折子戏 2020-12-03 07:17

Consider:

$smarty =& SESmarty::getInstance();

What is the & for?

3条回答
  •  渐次进展
    2020-12-03 07:55

    In PHP 4, it kind of (awkwardly) associated two variables.

    $j = 'original';
    $i =& $j;
    $i = 'modified';
    echo $j; // The output is 'modified'
    

    Likewise...

    $j = 'original';
    $i =& $j;
    $j = 'modified';
    echo $i; // The output is 'modified'
    

    Some of this was made a little less unpleasant when it comes to objects in PHP 5, but I think the heart of it is the same, so these examples should still be valid.

提交回复
热议问题