How do I get a property in a PHP based on a string? I’ll call it magic. So what is magic?
$obj->Name = 'something';
$get = $obj->Name;
would be like…
magic($obj, 'Name', 'something');
$get = magic($obj, 'Name');
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Like this
Or, if you have control over the class, implement the ArrayAccess interface and just do this