I read the other day that assigning values within if statements isn’t such a great idea.
To be honest i actually use this quite a lot e.g.
if(isset($_POST) && $post = $_POST) {
print_r($post)
}
Any idea why that isn’t optimal?
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.
Not least because it’s a common newbie mistake to forget that assignment and equality operators are different, so it can easily lead to confusion or difficult-to-detect bugs.
Readability of your code is more important than any micro-optimisations