vincej Posted November 17, 2010 Share Posted November 17, 2010 I often see the colon ( : ) being used in syntax however, no amount of searching through my text books or checking php.net reveals to me exactly what this is used for, when it is used and the exact definition of it's value. Intuitively it seems to mean ' or ' but I can't be sure when || is the proper operator for 'or' Can anyone point me towards a url for a succinct explanation ? thanks VJ Quote Link to comment https://forums.phpfreaks.com/topic/218994-newbie-question-on-syntax/ Share on other sites More sharing options...
Pikachu2000 Posted November 17, 2010 Share Posted November 17, 2010 If you're talking about something like echo isset($_POST['text']) ? "Field is {$_POST['text']}" : 'Field is not set'; That is ternary syntax, and is essentially shorthand for if( isset($_POST['text']) ) { echo "Field is {$_POST['text']}"; } else { echo 'Field is not set'; } More about it can be found on this page. Quote Link to comment https://forums.phpfreaks.com/topic/218994-newbie-question-on-syntax/#findComment-1135707 Share on other sites More sharing options...
mikosiko Posted November 17, 2010 Share Posted November 17, 2010 All depend of in which context you saw it.... could have multiples meanings... one is what Pikachu2000 mentioned. Quote Link to comment https://forums.phpfreaks.com/topic/218994-newbie-question-on-syntax/#findComment-1135710 Share on other sites More sharing options...
vincej Posted November 17, 2010 Author Share Posted November 17, 2010 well I see it in VirtueMart a lot - I still don't get what it means , eg <?php echo ps_product::image_tag( $product_thumb_image, 'class="browseProductImage" border="0" title="'.$product_name.'" alt="'.$product_name .'"' ) ?></a> OR / <td nowrap="nowrap" width="10%" align="right"><?php echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_COMPANY') ?>: </td> Quote Link to comment https://forums.phpfreaks.com/topic/218994-newbie-question-on-syntax/#findComment-1135727 Share on other sites More sharing options...
AbraCadaver Posted November 17, 2010 Share Posted November 17, 2010 All depend of in which context you saw it.... could have multiples meanings... one is what Pikachu2000 mentioned. Yes, here's another: http://php.net/manual/en/control-structures.alternative-syntax.php Quote Link to comment https://forums.phpfreaks.com/topic/218994-newbie-question-on-syntax/#findComment-1135728 Share on other sites More sharing options...
AbraCadaver Posted November 17, 2010 Share Posted November 17, 2010 well I see it in VirtueMart a lot - I still don't get what it means , eg <?php echo ps_product::image_tag( $product_thumb_image, 'class="browseProductImage" border="0" title="'.$product_name.'" alt="'.$product_name .'"' ) ?> That is a static method call, ps_product is the class and image_tag() is the method. Similar to an object method $object->method() except acting on a class staically instead of on an instance of the class. Read up on OOP in the PHP manual: http://us2.php.net/manual/en/language.oop5.php <td nowrap="nowrap" width="10%" align="right"><?php echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_COMPANY') ?>: </td> That is just a : in the HTML, notice it isn't inside the PHP tags. Quote Link to comment https://forums.phpfreaks.com/topic/218994-newbie-question-on-syntax/#findComment-1135730 Share on other sites More sharing options...
Pikachu2000 Posted November 17, 2010 Share Posted November 17, 2010 Well, this one here is pretty complicated . . . <td nowrap="nowrap" width="10%" align="right"><?php echo $VM_LANG->_('PHPSHOP_ORDER_PRINT_COMPANY') ?>: </td> It actually causes a colon to be echoed to the screen, like this : EDIT: Dang. AC beat me to this one. Quote Link to comment https://forums.phpfreaks.com/topic/218994-newbie-question-on-syntax/#findComment-1135731 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.