Page 1 of 1

[SOLVED]if or or then

Posted: Tue Dec 16, 2003 11:08 am
by vigge89
Does it exist any similar PHP code for the VB "if or then" syntax?

Code: Select all

if "something" or "something" then

Posted: Tue Dec 16, 2003 11:11 am
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

Posted: Tue Dec 16, 2003 11:14 am
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
}
?>

Posted: Tue Dec 16, 2003 11:21 am
by JayBird
what about

Code: Select all

<?php 
if (empty($name) || empty($url) || empty($desc)) { 
// Do something 
} 
?>
Mark

Posted: Tue Dec 16, 2003 11:23 am
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

Posted: Tue Dec 16, 2003 11:28 am
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

Posted: Tue Dec 16, 2003 11:28 am
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