Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



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

Have Programming Question? Ask it here!
 
 
 


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


Are objects passed by value or by reference?


Advertisement
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 Tutorials/Questions & Answers:
Advertisements
 

 

 

DMCA.com