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
vigge89
Forum Regular
Posts: 875 Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden
Post
by vigge89 » Tue Dec 16, 2003 11:08 am
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.
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Tue Dec 16, 2003 11:11 am
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
vigge89
Forum Regular
Posts: 875 Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden
Post
by vigge89 » Tue Dec 16, 2003 11:14 am
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
}
?>
JayBird
Admin
Posts: 4524 Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:
Post
by JayBird » Tue Dec 16, 2003 11:21 am
what about
Code: Select all
<?php
if (empty($name) || empty($url) || empty($desc)) {
// Do something
}
?>
Mark
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 » Tue Dec 16, 2003 11:23 am
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 » Tue Dec 16, 2003 11:28 am
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
vigge89
Forum Regular
Posts: 875 Joined: Wed Jul 30, 2003 3:29 am
Location: Sweden
Post
by vigge89 » Tue Dec 16, 2003 11:28 am
Bech100 wrote: what about
Code: Select all
<?php
if (empty($name) || empty($url) || empty($desc)) {
// Do something
}
?>
Mark
oh, that was it!
great!