Page 1 of 1

Object return value[solved]

Posted: Tue Mar 01, 2005 3:50 am
by AGISB
Following problem. I want to call an object and want to return 3 values.

php manual states to return an array so I do something like this in calculate funtion in the class.

Code: Select all

$value1 = 3.14;
$value2 = "This is a value";
$value3 = 1;
return array($value1, $value2, $value3);
So I call the object

Code: Select all

list ($val1, $val2, $val3) = $var->calculate();
when I echo out $val1, $val2 and $val3 they are empty allthough they should have values.

Any advice?

Posted: Tue Mar 01, 2005 4:18 am
by n00b Saibot

Code: Select all

$value1 = 3.14; 
$value2 = "This is a value"  //<--- This line is missing a semicolon
$value3 = 1; 
return array($value1, $value2, $value3);
Add the semicolon and then try. It is working after this.

Posted: Tue Mar 01, 2005 4:23 am
by AGISB
Nah this was just an example so I don't have to publish the big object

This error would show immideately on execution so its just a topic typo

Posted: Tue Mar 01, 2005 4:49 am
by AGISB
Never mind. This was a stupid call problem.

Above code works

Posted: Tue Mar 01, 2005 4:50 am
by n00b Saibot
try printing out the array just before return so that you know they are passing through. then see where the problem is.

EDIT: uh oh...beaten :)