Example:
$var = 'post_type_archive';
$name = 'some-archive';
$condition = 'is_'.$var;
if($condition($name))
Is that considered a big fat no-no? If so, how else could one accomplish something similar?
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.
It is not a bad practice when you limit the usage to certain cases. One of these cases might be dynamically calling functions based on the given GET parameters.
But I would recommend to use
call_user_func()instead. It makes clear what you are going to do and the code is much more readable. Remember to always check the existence of the function withis_callable().call_user_func()will not work with built-in functions though.