[SOLVED]if or or then

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

[SOLVED]if or or then

Post by vigge89 »

Does it exist any similar PHP code for the VB "if or then" syntax?

Code: Select all

if "something" or "something" then
Last edited by vigge89 on Tue Dec 16, 2003 11:43 am, edited 1 time in total.
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Like this?

Code: Select all

if ($something) {
    // Do something
} elseif($something_else) {
    // Do something else
} else {
   // Do something
}
or...

Code: Select all

if ($something || $something_else) {
   // Do something
} else {
   // Do something else
}
Depends on you logic which one you use

Mark
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

yes, but shorter, i already know that, but i forgot to mention it ;)
for example;

Code: Select all

<?php
if (empty($name) or empty($url) or empty($desc)) {
// Do something
}
?>
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

what about

Code: Select all

<?php 
if (empty($name) || empty($url) || empty($desc)) { 
// Do something 
} 
?>
Mark
User avatar
dull1554
Forum Regular
Posts: 680
Joined: Sat Nov 22, 2003 11:26 am
Location: 42:21:35.359N, 76:02:20.688W

Post by dull1554 »

then what your asking is whats the syntax of if, then
[syntax]
if(/*check something*/){
//then is what goes here
}
[/syntax]
i hope that was what your question was
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

The alternative syntax is like:

Code: Select all

If ($var == "that" || $var == "this"):
echo "that";
Else:
echo "its not that";
EndIf;
i'm not sure about using OR though, try it! ;)

-Nay
User avatar
vigge89
Forum Regular
Posts: 875
Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden

Post by vigge89 »

Bech100 wrote:what about

Code: Select all

<?php 
if (empty($name) || empty($url) || empty($desc)) { 
// Do something 
} 
?>
Mark
oh, that was it!
great! :D
Post Reply