- var_dump: documentation ( source)
<?php
class foo {
public $aVariableName = 'aValue';
function __construct() {
$this->a = "hello";
$this->b = "hi";
$this->val = "howdy";
$val = "a";
echo $this->{$val}; // outputs "hello"
echo "\n";
$val = "b";
echo $this->{$val}; // outputs "hi"
echo "\n";
echo $this->val; //outputs "howdy"
echo "\n";
echo $this->{"val"};
$this->setConfigParam('aVariableName', array('one', 'two', 'three'));
// echo $this->$aVariableName;
$name = 'aVariableName';
echo "\n";
var_dump($this->{$name});
echo "\n";
var_dump($this->_aConfigParams);
}
public function setConfigParam( $sName, $sValue )
{
if ( isset( $this->$sName ) ) {
$this->$sName = $sValue;
} else {
$this->_aConfigParams[$sName] = $sValue;
}
}
}
$foo = new foo();