Please look at the code, the array contains the table field names of the table
class User {
public $db_fields = array('id', 'username', 'password', 'first_name', 'last_name');
public $id;
public $username;
public $password;
public $first_name;
public $last_name;
}
The idea is to remove the public variables with a function so that it automatically creates public variable from the array which i can access ---
Example
I want to remove the
public $id;
public $username;
public $password;
public $first_name;
public $last_name;
section, and want this to be automatically generated by the $db_fields
array.
So that I can access the objects by
$user = new User();
$user->username = "Ismail";
What I did was
extract($db_fields);
but it gives an error:
Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in C:\xampp\htdocs\advphp\dbclass\extractex.php on line 3