webguync Posted April 28, 2009 Share Posted April 28, 2009 just curious as to the function of the colon is in this piece of PHP code. echo ('access=accept&uid='.$userID): .'&username='.urlencode($username); Link to comment https://forums.phpfreaks.com/topic/156014-explain-the-colon-in-this-piece-of-code/ Share on other sites More sharing options...
Mchl Posted April 28, 2009 Share Posted April 28, 2009 It makes this piece of code invalid. Link to comment https://forums.phpfreaks.com/topic/156014-explain-the-colon-in-this-piece-of-code/#findComment-821315 Share on other sites More sharing options...
Cosizzle Posted April 28, 2009 Share Posted April 28, 2009 is it within an if statement? ie <?php $a = (!empty($a)) ? TRUE : FALSE; ?> Link to comment https://forums.phpfreaks.com/topic/156014-explain-the-colon-in-this-piece-of-code/#findComment-821316 Share on other sites More sharing options...
webguync Posted April 28, 2009 Author Share Posted April 28, 2009 it is actually, it may be invalid the way it is now. if($scores->num_rows) { echo ('access=deny&record=true&uid='.$userID); }else { echo ('access=deny&record=none&uid='.$userID.'&lid='.$logID); } }else { echo ('access=accept&uid='.$userID): .'&username='.urlencode($username); } Link to comment https://forums.phpfreaks.com/topic/156014-explain-the-colon-in-this-piece-of-code/#findComment-821321 Share on other sites More sharing options...
Mchl Posted April 28, 2009 Share Posted April 28, 2009 is it within an if statement? ie <?php $a = (!empty($a)) ? TRUE : FALSE; ?> It's not an if statement. It's a ternary operator. You can't have language constructs as its parameters. webguync : My guess is that someone just left it here, while it should be part of a string to echo. Link to comment https://forums.phpfreaks.com/topic/156014-explain-the-colon-in-this-piece-of-code/#findComment-821323 Share on other sites More sharing options...
nankoweap Posted April 28, 2009 Share Posted April 28, 2009 it is actually, it may be invalid the way it is now. if($scores->num_rows) { echo ('access=deny&record=true&uid='.$userID); } else { echo ('access=deny&record=none&uid='.$userID.'&lid='.$logID); } else { echo ('access=accept&uid='.$userID): .'&username='.urlencode($username); } given the code you posted, that colon doesn't matter cuz it's failing before that bit of code is parsed. can't have two else's. and something has to be done with that colon too unless that's some php code i'm not familiar with. jason Link to comment https://forums.phpfreaks.com/topic/156014-explain-the-colon-in-this-piece-of-code/#findComment-821335 Share on other sites More sharing options...
Mchl Posted April 28, 2009 Share Posted April 28, 2009 given the code you posted, that colon doesn't matter cuz it's failing before that bit of code is parsed. can't have two else's. It seems that second else is for yet another if above the one that was posted. Link to comment https://forums.phpfreaks.com/topic/156014-explain-the-colon-in-this-piece-of-code/#findComment-821340 Share on other sites More sharing options...
nankoweap Posted April 28, 2009 Share Posted April 28, 2009 hmmm... i reckon that's possible. uuuuhhhhggg! Link to comment https://forums.phpfreaks.com/topic/156014-explain-the-colon-in-this-piece-of-code/#findComment-821347 Share on other sites More sharing options...
webguync Posted April 28, 2009 Author Share Posted April 28, 2009 your right another if statement that I didn't include in the code post. I will take out the colon since it seems to be an error. Link to comment https://forums.phpfreaks.com/topic/156014-explain-the-colon-in-this-piece-of-code/#findComment-821352 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.