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? 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; ?> 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! Link to comment https://forums.phpfreaks.com/topic/85841-solved-unexpected-t_if/#findComment-438143 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.