I have a PHP Class with a Constructor and some Methods. Every Method need to have the same return stdClass Object. Only a few properties in each functoin of the stdClass Object should be diffrent from the default one(like the property value
or status
). How would you do that? I mean, i can define in every function an stdClass Object with all properties, but as I said, I only need to change a few properties in each function for the return.
Examplecode which doesn't work:
<?
class Person{
public $sName;
public $oReturn = new stdClass();
$oReturn->status = 200;
$oReturn->value = "Personname";
function __construct($sName) {
$this->sName = $sName;
}
public function something($oData){
//Declaration
$this->oReturn->value = $oData->newName;
//Main
//Return
return $this->oReturn;
}
}
?>