View Single Post
  #28 (permalink)  
Old 04-29-09, 11:20 PM
Jcbones Jcbones is offline
Aspiring Coder
 
Join Date: Mar 2009
Location: North Carolina, USA
Posts: 516
Thanks: 5
Thanked 47 Times in 44 Posts
Quote:
I don't understand how the following declarations works, or what they mean. How is the notation $ProdID = $Order[0] ? $Order[0] : ""; read, or what does it mean?
This is just an easy and fast way to write an if/else statement. Syntax is as follows

($argument) ? 'true' : 'false';

So,

PHP Code:



//if $Order[0] returns true, set $ProdID to $Order[0], else set it as NULL;
$ProdID = ($Order[0]) ? $Order[0] : NULL

//Same as above
if($Order[0] != NULL)
  {
      
$ProdID $Order[0];
  }
else
  { 
      
$ProdID NULL;
  } 
Reply With Quote