Returning a Value by Reference : Return Value « Functions « PHP






Returning a Value by Reference

 
<?php

    function &find_var($one, $two, $three) {

        if(($one > 0) && ($one <= 10)) return $one;
        if(($two > 0) && ($two <= 10)) return $two;
        if(($three > 0) && ($three <= 10)) return $three;

    }

    $c_one = 'foo';
    $c_two = 42;
    $c_three = 4;

    $right_var = &find_var($c_one, $c_two, $c_three);

    $right_var++;

    echo "The value of \$c_three and \$right_var are: ";
    echo "$c_three and $right_var<BR>\n";

?>
  
  








Related examples in the same category

1.Function return more than one value
2.Math Function Library
3.A Function That Returns a Value
4.Function Requiring Two Arguments
5.A Function That Returns a Value
6.Functions that return true or false
7.Returning a value from a function
8.Returning an array from a function
9.Returning a list an array from function
10.Returning Values by Reference
11.Returning by Reference
12.Returning More Than One Value
13.Multiple return statements in a function
14.return multiple values from a function
15.Using an array returned from a function
16.Passing Arguments and Returning Values by Reference
17.User-Defined Function to Determine a Leap Year