Results 1 to 10 of 10

Thread: Variable reference, unexpected output

Threaded View

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2005
    Location
    Cebu
    Posts
    607

    Resolved Variable reference, unexpected output

    I've got this code and I expect to output 5 and 5 as the result but outputs 4 and 5. Please explain a bit, quite confused.
    PHP Code:
    <?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";

    ?>
    Thanks in advance.
    Last edited by nebulom; Jul 24th, 2005 at 08:28 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width