takn25 Posted April 21, 2011 Share Posted April 21, 2011 Hi again, Here is the code $string .= (substr($string,-1) == '-') ? '' : '-'; I know what this code does but to increase my knowledge could some one tell me what is the question mark symbol for ( ? ) and what is the colon doing. As I have seen the ? in a lot of scripts but have no clue what it does and what its used for cheers! Link to comment https://forums.phpfreaks.com/topic/234387-want-to-know-whats-going-on-here/ Share on other sites More sharing options...
Maq Posted April 21, 2011 Share Posted April 21, 2011 It's shorthand for an if/else block. Basically, it checks to see if the last character is a '-', if it is, concatenate nothing, if not, it will add a '-' on the end of the string. Read this - http://us3.php.net/ternary Link to comment https://forums.phpfreaks.com/topic/234387-want-to-know-whats-going-on-here/#findComment-1204629 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.