I'm trying to assign $GLOBALS['a'] variable in function from class, but haven't succeeded.
Here is my code:
<?php
$GLOBALS['a'] = "alter";
class db_data
{
public $a;
function __construct()
{
$this->a = $GLOBALS['a'];
}
}
$db = new db_data;
echo $db->$a;
?>
And produced this error:
Notice: Undefined property: db_data::$alter.....
I tried to search on SO for this, but all questions were different and it did not resolve my problem.
echo $db->a;