|
Posted by Thomas Mlynarczyk on 10/13/07 12:15
Also sprach BoneIdol:
> Anyway to do it?
No. You could try this (not tested, though):
$foo = 'bar';
doSomething( compact( 'foo' ) );
function doSomething( $aVar )
{
list( $sVarName, $xVarValue ) = each( $aVar );
echo "The variable is called $sVarName and has the value $xVarValue.\n";
}
With objects in PHP5 you can use the __set()/__get()/__call() magic
functions (not tested either):
class Foo
{
private $_aVars = array();
public function __set( $sName, $xValue )
{
echo "Setting $sName to value $xValue.\n";
$this->_aVars[$sName] = $xValue;
}
public function __get( $sName )
{
echo "Getting $sName.\n";
return $this->_aVars[$sName];
}
}
$oFoo = new Foo;
$oFoo->bar = 'baz';
echo $oFoo->bar;
But why do you need such a functionality? Maybe there is a solution to your
problem (whatever it is) which does not require it?
Greetings,
Thomas
Navigation:
[Reply to this message]
|