Call By Value
In this method, only values of actual parameters are passing to the function. So there are two addresses stored in memory. Making changes in the passing parameter does not affect the actual parameter.
Example
- <?php
- function increment($var){
- $var++;
- return $var;
- }
- $a = 5;
- $b = increment($a);
- echo $a; //Output: 5
- echo $b; //Output: 6
- ?>
Call by Reference
In this method, the address of actual parameters is passing to the function. So any change made by function affects actual parameter value.
Example
- <?php
- function increment(&$var){
- $var++;
- return $var;
- }
- $a = 5;
- $b = increment($a);
- echo $a; //Output: 6
- echo $b; //Output: 6
- ?>

ankit ranaPosted Apr 28, 2020, 9:27 PM
Bhai ye program to humare concept bhi hila ra hai
Farzina SahinPosted Apr 12, 2017, 7:14 AM
This post is confusing
Jay PatelPosted Jul 12, 2016, 3:07 AM
Call by value example is wrong example plz post right example
Mahesh ChandPosted Dec 29, 2012, 9:50 PM
Vinod, There is no need to zoom images. Keep the original size. Cheers!