PHP函数引用

I'm getting a fatal error trying to modify a variable that was passed by reference. I've looked at documentation on referencing passing in PHP functions and I can't figure out what I'm doing different. I found that if I remove the reference (ampersand) on t0 and t1 then I can assign it without a fatal error; however, I need to modify t0 and t1 for the tracing. I'm using PHP 5.5.9 if that matters.

The context of my problem is for a raytracer, and inside the sphere intersect method. The function call looks like:

if($obj->intersect($ray, $t0, $t1)) { ... }

The intersect method looks like:

function intersect(Ray $ray, &$t0, &$t1) {
// if discrim is >= 0 go on
$discrim = $b * $b - (4.0 * $a * $c);
if($discrim >= 0) {
$t0 = (-1.0 * $b - sqrt($discrim)) / (2.0 * $a); // error ... }

The program runs if I change the function definition to:

function intersect(Ray $ray, $t0, $t1) { ... 

An alternative to references is to make the function return the values of $t0 and $t1:

// Modify the function to return the new values of $t0 and $t1
function intersect(Ray $ray, $t0, $t1)
{
    // Function code here, including the modification of $t0 and $t1

    // $result is the value previously returned by function (boolean, I guess)
    return array($result, $t0, $t1);
}


// Modify the code that calls the function to match its new behaviour
list($res, $t0, $t1) = $obj->intersect($ray, $t0, $t1);
if ($res) { ... }

If the function does not use the initial values of parameters $t0 and $t1 then they can be removed from the parameters list.