deepman007 Posted March 20, 2008 Share Posted March 20, 2008 Hi I'm new to PHP and I saw this "$sku_stock = (allowBackOrders) ? "" : " AND S.SKU_Stock > 0"; " What does it mean? I dont understand "? :" thanks Link to comment https://forums.phpfreaks.com/topic/97022-syntax-question/ Share on other sites More sharing options...
pocobueno1388 Posted March 20, 2008 Share Posted March 20, 2008 This is called the ternary operator, it is the short way of writing an if/else statement. This: $sku_stock = (allowBackOrders) ? "" : " AND S.SKU_Stock > 0"; Is the short version of writing: <?php if (allowBackOrders){ $sku_stock = ""; } else { $sku_stock = " AND S.SKU_Stock > 0"; } ?> Link to comment https://forums.phpfreaks.com/topic/97022-syntax-question/#findComment-496486 Share on other sites More sharing options...
deepman007 Posted March 21, 2008 Author Share Posted March 21, 2008 you can put Query " AND S.SKU_Stock >0 to a varible ? Thanks Link to comment https://forums.phpfreaks.com/topic/97022-syntax-question/#findComment-497671 Share on other sites More sharing options...
BlueSkyIS Posted March 21, 2008 Share Posted March 21, 2008 yes, sure. it's a string: $var = " AND S.SKU_Stock > 0"; Link to comment https://forums.phpfreaks.com/topic/97022-syntax-question/#findComment-497688 Share on other sites More sharing options...
Orio Posted March 21, 2008 Share Posted March 21, 2008 If you still need explanations, check the manual: http://www.php.net/manual/en/language.operators.comparison.php Scroll down a bit. Orio. Link to comment https://forums.phpfreaks.com/topic/97022-syntax-question/#findComment-497693 Share on other sites More sharing options...
deepman007 Posted March 21, 2008 Author Share Posted March 21, 2008 Thank you very much Link to comment https://forums.phpfreaks.com/topic/97022-syntax-question/#findComment-497753 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.