monkeytooth Posted October 21, 2010 Share Posted October 21, 2010 $_GET['id'] = (empty($_GET['id'])) ? 0 : $_GET['id']; I'm going over someones code, the site is super flawed, Ive got to much going on at once and I can't wrap my head around that. Is it if the string is empty or 0 then use the get variable or is it something else? Quote Link to comment https://forums.phpfreaks.com/topic/216437-what-does-this-type-of-statement-mean/ Share on other sites More sharing options...
marcus Posted October 21, 2010 Share Posted October 21, 2010 It's a ternary operator. It's a condensed if statement practically. $var = (CONDITIONAL STATEMENT) ? TRUE : FALSE; Quote Link to comment https://forums.phpfreaks.com/topic/216437-what-does-this-type-of-statement-mean/#findComment-1124700 Share on other sites More sharing options...
trq Posted October 21, 2010 Share Posted October 21, 2010 It is the ternary operator and is basically a short version of if else. if (empty($_GET['id'])) { $_GET['id'] = 0; } else { $_GET['id'] = $_GET['id']; } Quote Link to comment https://forums.phpfreaks.com/topic/216437-what-does-this-type-of-statement-mean/#findComment-1124701 Share on other sites More sharing options...
monkeytooth Posted October 21, 2010 Author Share Posted October 21, 2010 Thats what I thought, I dont typically use statements like that so I wanted to double check with people here, thanks Quote Link to comment https://forums.phpfreaks.com/topic/216437-what-does-this-type-of-statement-mean/#findComment-1124706 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.