An ampersand just before the function name will return a reference to the variable instead of returning its value. 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. In PHP 4, objects were assigned by value, just like any other value. This is highly counter-intuitive and opposite to how most other languages work.
Example: This example demonstrate the concept behind putting an ampersand to start a PHP function.
The property of the object returned by the getValue() function would be set instead of the copy as it would be without using reference syntax. Unlike parameter passing, here you have to use the ampersand in both the places to indicate that you want to return by reference rather than a copy and to indicate that reference binding, rather than usual assignment, should be done for $myValue.
- CSS | border-start-start-radius Property
- CSS | grid-row-start Property
- HTML | <ol> start Attribute
- HTML | start Attribute
- HTML | DOM Ol start Property
- CSS | border-start-end-radius Property
- CSS | border-end-start-radius Property
- CSS | padding-block-start Property
- HTML | Marquee start method
- CSS | margin-inline-start Property
- Begin Web Development with a Head Start
- CSS | margin-block-start Property
- CSS | border-inline-start Property
- CSS | border-block-start Property
- CSS | inset-inline-start Property
- CSS | padding-inline-start Property
- CSS | grid-column-start Property
- CSS | inset-block-start Property
- CSS | border-block-start-color Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.