I have a array i want its value to be "public $somevariable". Here is my function how it looks like.
public function __construct(){
global $database;
$result = $database->query("SHOW COLUMNS FROM ".self::$tabel_name."");
if (!$result) {
echo 'Could not run query: ' . mysql_error();
exit;
}
if (mysql_num_rows($result) > 0) {
$attributes_var = array();
while ($row = $database->fetch_array($result)) {
$attributes_var[] = $row[0];
}
}
foreach($attributes_var as $key)
{
public $$key;
}
}
But its showing syntax error on "public $$key". I want to use the dynamic generated variable as public variable and want to use them outside the class.
Any suggestion?
Thank you!