How do you return an object from a function? Take the following
snippet...
class Stuff
{
public $nNum;
public $szText;
}
function MakeStuff
{
$oObject = new Stuff;
$oObject->nNum = 123;
$oObject->szText = "Hello";
return $oObject;
}
function EntryPoint
{
$oStuff = MakeStuff(); // oStuff will equal NULL
}
I've tried all sorts but i just can't get an object passed out of a
function. Its mainly useful for returning a collection of errors and
the like. But how do you do it in php5?
If anyone could help i would be eternally grateful.
snippet...
class Stuff
{
public $nNum;
public $szText;
}
function MakeStuff
{
$oObject = new Stuff;
$oObject->nNum = 123;
$oObject->szText = "Hello";
return $oObject;
}
function EntryPoint
{
$oStuff = MakeStuff(); // oStuff will equal NULL
}
I've tried all sorts but i just can't get an object passed out of a
function. Its mainly useful for returning a collection of errors and
the like. But how do you do it in php5?
If anyone could help i would be eternally grateful.
Comment