PHP Call By Value

PHP allows you to call function by value and reference both. In case of PHP call by value, actual value is not modified if it is modified inside the function.

Let’s understand the concept of call by value by the help of examples.

Example 1

In this example, variable $str is passed to the adder function where it is concatenated with ‘Call By Value’ string. But, printing $str variable results ‘Hello’ only. It is because changes are done in the local variable $str2 only. It doesn’t reflect to $str variable.


Example 2

Let’s understand PHP call by value concept through another example.


Spread the love

One comment

  1. I am also commenting to let you be aware of what a fabulous encounter my cousin’s daughter undergone studying your blog. She figured out a good number of things, most notably how it is like to possess an ideal coaching nature to let other folks really easily comprehend various tricky matters. You actually did more than visitors’ desires. Many thanks for coming up with these important, healthy, informative and as well as unique tips on that topic to Jane.

Leave a Reply

Your email address will not be published. Required fields are marked *