Suppose I have a class object defined in php where each variable in the class is defined. Sort of:
class UserVO {
public $id;
public $name;
}
Now I have a function in another class that expects an array ($ data).
function save_user($data) {
}
How to tell php that the parameter $ data should be entered as UserVO? Then I could complete the code to do something like:
$something = $data->id;
$else = $data->name;
I am assuming something like the following, but this clearly does not work
$my_var = $data as new userVO();
Jonob source
share