Object as regular value?
Posted: Fri Aug 14, 2009 6:58 am
Is it possible to create object that acts like regular values.
Here is sample of class definition:
Is it possible to create class like this one that could be used in expressions
like.
$intValue = new IntValue();
$intValue = 5; // calls setValue(5)
//calls getValue
$result = $intValue * 100;
echo $result // prints 500
Here is sample of class definition:
Code: Select all
class IntValue
{
private $_value;
function setValue($val)
{
$this->_value = $val;
}
function getValue()
{
return $this->_value;
}
}
like.
$intValue = new IntValue();
$intValue = 5; // calls setValue(5)
//calls getValue
$result = $intValue * 100;
echo $result // prints 500