technoczech Posted October 5, 2009 Posted October 5, 2009 Hi, I'm attempting to troubleshoot a problem I'm having, and can't find a resource that explains how this if statement reads: if ($confirmation = $payment_modules->confirmation()) { Why is this a single equal sign and not a double? (Changing it to a double doesn't make my problem go away...) Many, many thanks in advance!
technoczech Posted October 5, 2009 Author Posted October 5, 2009 Hi, I'm attempting to troubleshoot a problem I'm having, and can't find a resource that explains how this if statement reads: if ($confirmation = $payment_modules->confirmation()) { Why is this a single equal sign and not a double? (Changing it to a double doesn't make my problem go away...) Many, many thanks in advance! Got a super fast reply from Stack Overflow. Posting it here in case anyone else comes across this thread later: It's a form of shorthand, which is exactly equivalent to this: $confirmation = $payment_modules->confirmation(); if ($confirmation) { }
MrPhil Posted October 5, 2009 Posted October 5, 2009 It's simply a shortcut, or shorthand, popularized by the C language. Unfortunately, it has led to many errors as programmers intending to test for equivalence if (a == b) { forget an '=' and end up writing an assignment if (a = b) {. If you're a wizard and don't make "stoopid" mistakes, it's a nice convenience. If you're merely human, it will bite you in the behind!
Recommended Posts
Archived
This topic is now archived and is closed to further replies.