lopes_andre Posted February 27, 2009 Share Posted February 27, 2009 Hi, I'am trying to write some code. I'am trying to do this, but the code is not working. How to use the OR in IF statement? Sorry my english. if ($_SERVER['PHP_SELF'] != "/alarmes.php" OR $_SERVER['PHP_SELF'] != "/register.php") { echo "123"; } else { echo ""; } Best Regards, André Link to comment https://forums.phpfreaks.com/topic/147091-how-to-use-or-in-if-statement/ Share on other sites More sharing options...
Michdd Posted February 27, 2009 Share Posted February 27, 2009 or is || if ($_SERVER['PHP_SELF'] != "/alarmes.php" || $_SERVER['PHP_SELF'] != "/register.php") { echo "123"; } else { echo ""; } Link to comment https://forums.phpfreaks.com/topic/147091-how-to-use-or-in-if-statement/#findComment-772204 Share on other sites More sharing options...
samshel Posted February 27, 2009 Share Posted February 27, 2009 if ($_SERVER['PHP_SELF'] != "/alarmes.php" || $_SERVER['PHP_SELF'] != "/register.php") { } else { echo ""; } Link to comment https://forums.phpfreaks.com/topic/147091-how-to-use-or-in-if-statement/#findComment-772205 Share on other sites More sharing options...
lopes_andre Posted February 27, 2009 Author Share Posted February 27, 2009 It is not working. Only works if I use one statement if ($_SERVER['PHP_SELF'] != "/alarmes.php") { } else { echo ""; } What can I try to solve this? Best Regards Link to comment https://forums.phpfreaks.com/topic/147091-how-to-use-or-in-if-statement/#findComment-772211 Share on other sites More sharing options...
samshel Posted February 27, 2009 Share Posted February 27, 2009 what do u want to do ? if page is not register.php and alarmes.php u want to allow ? if ($_SERVER['PHP_SELF'] != "/alarmes.php" && $_SERVER['PHP_SELF'] != "/register.php") { } else { echo ""; } OR generally got with == for != AND should be used. not necessary but thumb rule Link to comment https://forums.phpfreaks.com/topic/147091-how-to-use-or-in-if-statement/#findComment-772215 Share on other sites More sharing options...
lopes_andre Posted February 27, 2009 Author Share Posted February 27, 2009 Great! It is working with && Thanks! Link to comment https://forums.phpfreaks.com/topic/147091-how-to-use-or-in-if-statement/#findComment-772217 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.