By default, PHP variables are passed by value as the function arguments in PHP. When variables in PHP is passed by value, the scope of the variable defined at function level bound within the scope of function. Changing either of the variables doesn’t have any effect on either of the variables.
Function geeksforgeeks Global geeksforgeeks
Pass by reference: When variables are passed by reference, use & (ampersand) symbol need to be added before variable argument. For example: function( &$x ). Scope of both global and function variable becomes global as both variables are defined by same reference. Therefore, whenever global variable is change, variable inside function also gets changed and vice-versa is applicable.
Function geeksforgeeks Function geeksforgeeks
- Perl | Pass By Reference
- How to pass integer by reference in Java
- Why do we need reference variables if we have pointers
- How to pass form variables from one page to other page in PHP ?
- How to pass string to a component using Angular2 ?
- How to pass two parameters to EventEmitter in Angular 9 ?
- How to pass query parameters with a routerLink ?
- PHP | Ds\Map Functions Complete Reference
- Passing Reference to a Pointer in C++
- HTML | DOM Complete Reference
- CSS | Selectors Complete Reference
- CSS | Functions Complete Reference
- PHP | Ds\Set Functions Complete Reference
- CSS | Properties Complete Reference
- PHP | GMP Functions Complete Reference
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.