Home Answers Viewqa PHP Are objects passed by value or by reference?

 
 


brijesh
Are objects passed by value or by reference?
1 Answer(s)      2 years and 6 months ago
Posted in : PHP

Are objects passed by value or by reference?

View Answers

November 15, 2010 at 1:24 PM


Hi everyone,

Everything is passed by value.

Example :

<?php
    function fruitName($name = "apple")
    {
     return "Fruit is $name.";
    }
    echo fruitName();
    echo "<br>";
    echo fruitName(null);
    echo "<br>";
    echo fruitName("Strawberry");
 ?>

Output :

Fruit is apple.
Fruit is .
Fruit is Strawberry.

Thanks









Related Pages:

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.