- var_dump: documentation ( source)
<?php
class User {
public $username = 'user';
public $test;
}
class Test {
public $here = 'here';
}
$user = new User;
$test = new Test;
$user->test = $test;
$string = 'username';
var_dump($user->$string);
echo '<br>';
$string = 'test';
var_dump($user->test);
echo '<br>';
$string = 'test->here';
echo $user[$string];