开发者

References in function definitions and parameter definitions

开发者 https://www.devze.com 2023-01-17 10:46 出处:网络
Heya, so I understand how the following should be used: function test(&$obj) { {...} } But wha开发者_开发问答t does the following represent?

Heya, so I understand how the following should be used:

function test(&$obj) {
    {...}
}

But wha开发者_开发问答t does the following represent?

function &test(&$obj) {
    {...}
}

Any help would be appreciated.


This declaration:

function &test(&$obj)

Represents a function that takes in a reference to a variable as a parameter and returns a variable by reference.


The function will return reference to the variable instead of the value.

See Returning References (PHP manual) for more information.

0

精彩评论

暂无评论...
验证码 换一张
取 消