ted_chou12 Posted March 20, 2007 Share Posted March 20, 2007 $username = isset($_POST["username"])?$_POST["username"]:""; This is a piece of code from a script I have found, but I dont understand what this means, I tried searching it in manual, however, only found about the isset() not the ?:"" parts, can anyone kindly explain to me what the code means? Thanks Ted Link to comment https://forums.phpfreaks.com/topic/43499-solved-can-anyone-tell-me-what-this-expression-means/ Share on other sites More sharing options...
obsidian Posted March 20, 2007 Share Posted March 20, 2007 That's called the ternary operator. It's the equivalent of saying the following: <?php if (isset($_POST['username'])) { $username = $_POST['username']; } else { $username = ''; } ?> Link to comment https://forums.phpfreaks.com/topic/43499-solved-can-anyone-tell-me-what-this-expression-means/#findComment-211236 Share on other sites More sharing options...
per1os Posted March 20, 2007 Share Posted March 20, 2007 if the post username isset then (?) set username to post username else ( set it to "" Link to comment https://forums.phpfreaks.com/topic/43499-solved-can-anyone-tell-me-what-this-expression-means/#findComment-211246 Share on other sites More sharing options...
ted_chou12 Posted March 20, 2007 Author Share Posted March 20, 2007 thanks, I see how it works now. Link to comment https://forums.phpfreaks.com/topic/43499-solved-can-anyone-tell-me-what-this-expression-means/#findComment-211248 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.