Re: if and...

From: Date: Tue, 01 Jul 2003 01:23:58 +0000
Subject: Re: if and...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-153503@lists.php.net to get a copy of this message
On Mon, 2003-06-30 at 18:09, Steve Marquez wrote: > I am trying to get php to use two conditions. > > <?php > > if ($biz = my_business and $id_num = "1"){ > > echo "stuff...." > > } > > if ($biz = "my_business" and $id_num ="2"){ > > echo "other stuff...." > > } > > ?> > > My question Is, I am not sure if the "and" is correct, it does not work. Is > there another way to do this? I have tried a plus (+), a (,) and nothing > seems to work. > > Could someone please help? > > Thanks! > > Steve Marquez This is all explained in the manual here: http://www.php.net/manual/en/language.operators.php Essentially, you probably want && instead of and (although and also checks for an 'and' condition, it has lower precedence than &&). Also, you need to use == or === to check for equality. = is the assignment operator, and attempts to assign the value of the expression on the right to the variable on the left. Also, you should quote any strings. So: if ($biz == 'my_business' && $id_num == '2') { . . . } ...etc. Hope this helps, Torben -- Torben Wilson <torben@php.net> +1.604.709.0506 http://www.thebuttlesschaps.com http://www.inflatableeye.com http://www.hybrid17.com http://www.themainonmain.com -----==== Boycott Starbucks! http://www.haidabuckscafe.com ====-----

« previous php.general (#153503) next »