I am trying to convert an arary to object but I am getting this error message.
Message: ‘Creation of dynamic property AppModelsUser::$name is deprecated’
This is where the value name is used.
$stmt = $db->prepare($sql);
$stmt->bindValue(':name', $this->name, PDO::PARAM_STR);
I have insantiate a standard class as a variable, and loop through your array while re-assigning the values
public function __construct($data)
{
foreach ($data as $key => $value) {
$this->$key = $value;
};
}
Why this is happening?
Is this should to turn ‘name’ => ‘Dimitris to $user->name = ‘Dimitris’?