Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP references (ampersand) [duplicate]

Tags:

php

reference

I am Studying PHP, and i wanted to ask about references,

My question: What is the difference when you define function with (&) and when you call function with (&) same is for parameters, In other words what the difference when i put (&) at the definition between when i call the function/parameter with (&), thank you all and have a nice day.

like image 373
Blanktext Avatar asked Feb 10 '26 00:02

Blanktext


1 Answers

Returning by reference is useful when you want to use a function to find to which variable a reference should be bound. Do not use return-by-reference to increase performance. The engine will automatically optimize this on its own. Only return references when you have a valid technical reason to do so. To return references, use this syntax:

From the PHP manual Returning References

like image 105
bretterer Avatar answered Feb 12 '26 15:02

bretterer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!