if condition statement delimma

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
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

if condition statement delimma

Post by kendall »

Hello,

i am having a difficult time understanding an if statement that i am trying to understand

i have coded an iff statement -

if($action == ('register' ||'renew'||'transfer')){

do the thing
}elseif($action == 'hosting'){
do the damn thing
}

now on $action = register

it - 'do the thing'

but on $action = hosting

it - 'do the thing' when it should 'do the damn thing'

what is wrong with my syntax?

Kendall
User avatar
d1223m
Forum Commoner
Posts: 80
Joined: Mon Mar 31, 2003 5:15 am
Location: UK, West Sussex

Post by d1223m »

Code: Select all

if($action == ('register' ||'renew'||'transfer')){
this is illegal
you must do

Code: Select all

if($action == 'register' || $action=='renew' || $action=='transfer')){
User avatar
Wayne
Forum Contributor
Posts: 339
Joined: Wed Jun 05, 2002 10:59 am

Post by Wayne »

Code: Select all

if ( ( $action == 'register' ) || ( $action == 'renew' ) || ( $action == 'transfer' ) ) {
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Yea they both work good.

the php manual has some good info on the if() statement, and also it's many related functions.
Post Reply