For example, let's say I have the file "other.php" that contains this code
class Building
{
public $name;
function __construct($name)
{
$this->$name = $name;
}
}
$bd = new Building("Name");
echo $bd->$name;
This returns errors like this:
Notice: Undefined variable: name in (...)
Fatal error: Cannot access empty property in (...)
And I wish for an output like
Name
How do I access PHP object properties in such a fashion? Thank you.