示例#1
0
    global $a;
    return $a;
}
function &returnReference()
{
    global $a;
    return $a;
}
function foo(&$ref)
{
    var_dump($ref);
    $ref = "changed";
}
echo "Pass a function call that returns a value:\n";
$a = "original";
foo(returnVal());
var_dump($a);
echo "Pass a function call that returns a reference:\n";
$a = "original";
foo(returnReference());
var_dump($a);
echo "\nPass a static method call that returns a value:\n";
$a = "original";
foo(C::sreturnVal());
var_dump($a);
echo "Pass a static method call that returns a reference:\n";
$a = "original";
foo(C::sreturnReference());
var_dump($a);
$myC = new C();
echo "\nPass a method call that returns a value:\n";
示例#2
0
<?php

function &returnRef()
{
    global $a;
    return $a;
}
function returnVal()
{
    global $a;
    return $a;
}
$a = "original";
$b =& returnVal();
$b = "changed";
var_dump($a);
//expecting warning + "original"
$a = "original";
$b =& returnRef();
$b = "changed";
var_dump($a);
//expecting "changed"
示例#3
0
function &testReturnValByRef()
{
    return returnVal();
}