Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

What in the world is this if statement saying?


technoczech

Recommended Posts

Posted

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!

Posted

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) {

 

}

Posted

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...