40esp Posted January 13, 2008 Share Posted January 13, 2008 I just dont understand this. Usually T_IF errors are related to a missing semicolon before an if. heres my code: <?php $day = if ($_GET['d'] > 1) { $_GET['d']; } else { echo "0"; } $month = if ($_GET['m'] > 1) { $_GET['m']; } else { echo "0"; } $year = if ($_GET['y'] > 1) { $_GET['y']; } else { echo "0"; } ?> can you help me? Quote Link to comment https://forums.phpfreaks.com/topic/85841-solved-unexpected-t_if/ Share on other sites More sharing options...
Ken2k7 Posted January 13, 2008 Share Posted January 13, 2008 Remove all the echos. Alternatively, this is shorter: <?php $day = ($_GET['d'] > 1)? $_GET['d'] : 0; $month = ($_GET['m'] > 1)? $_GET['m'] : 0; $year = ($_GET['y'] > 1)? $_GET['y'] : 0; ?> Quote Link to comment https://forums.phpfreaks.com/topic/85841-solved-unexpected-t_if/#findComment-438136 Share on other sites More sharing options...
40esp Posted January 13, 2008 Author Share Posted January 13, 2008 Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/85841-solved-unexpected-t_if/#findComment-438143 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.