What does =& mean in PHP?

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

Consider:

$smarty =& SESmarty::getInstance();

What is the & for?

3条回答
  •  北海茫月
    2020-12-03 08:05

    References are used to alias variables and were necessary to use the old object system efficiently.

    In PHP 4, objects behaved like any other value type, that is, assignment would create a copy of the object. If you wanted to avoid this, you had to use a reference as in your example code.

    With PHP 5, object variables no longer contain the object itself, but a handle (AKA object identifier) and assignment will only copy the handle. Using a reference is no longer necessary.

提交回复
热议问题