brentmoeller Posted March 30, 2011 Share Posted March 30, 2011 In theory would these two code snippets give the same results ? if ((!isset($_GET['id']) || trim($_GET['id']) == '')) or die('missing data'); if ((!isset($_GET['id']) || trim($_GET['id']) == '')) { die('missing data'); } Link to comment https://forums.phpfreaks.com/topic/232123-or-die/ Share on other sites More sharing options...
ngreenwood6 Posted March 30, 2011 Share Posted March 30, 2011 not to be a rude or anything but did you try it? the best way to test a theory is by putting it in practice. Also you can just do: if (!isset($_GET['id']) || trim($_GET['id']) == '') die('missing data'); Link to comment https://forums.phpfreaks.com/topic/232123-or-die/#findComment-1194013 Share on other sites More sharing options...
btherl Posted March 30, 2011 Share Posted March 30, 2011 The syntax of the first one is a little messed up. But when used correctly, you can use "or die" in the same way as you would use an "if". I would expect the same results when using either approach, but you need to invert the condition, because "or die" triggers on false, but "if" triggers on true. Link to comment https://forums.phpfreaks.com/topic/232123-or-die/#findComment-1194115 Share on other sites More sharing options...
trq Posted March 30, 2011 Share Posted March 30, 2011 or is also lower in precedence than || but it shouldn't make any difference in this case. Link to comment https://forums.phpfreaks.com/topic/232123-or-die/#findComment-1194118 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.