Variable params and return values
| From: | Duncan Dickinson | Date: | Tue, 25 Apr 2000 06:31:55 +0000 |
| Subject: | Variable params and return values | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-14037@lists.php.net to get a copy of this message | ||
Hi,
Apologies if this has already been discussed. I am experiencing 2
problems :(
1. When I try to set a variable parameter to an object stored in an
array, the calling code does not receive the value of the parameter
set by the function. An example of this is function x.
2. Returning a reference causes a syntax error.
The easy workaround for 2 is to use variable parameters, as seen in
function z. The problem really occurs when I want to set a reference
to an object inside an array.
Is this functionality planned for PHP4?
Cheers,
Duncan
<?php
error_reporting(63);
class test{
var $msg = "Roar";
}
function x(&$obj){
$y = array("x"=>new test);
$obj = &$y["x"];
}
function z(&$obj) {
$obj = new test;
}
x($o);
var_dump($o);
echo "<hr>";
z($p);
var_dump($p);
//function y(){
// $y = array("x"=>new test);
// return &$y["x"];
//}
//echo "result: " . y() . "<br>";
?>