Page 1 of 1

And If condition?

Posted: Wed Aug 12, 2009 7:44 pm
by rozkan
Hello, i was wondering how can i add and if condition. I am pretty sure there should be a condition for that just couldn't figure out, here's example:
if ($age <= 18) {

echo 'You are a little wannabe get out of this site now!';

}

else {
echo "<p>Thank you, <b>$name</b>, for the following comments:<br /> <tt>$comments</tt></p> <p>We will reply to you at <i>$email</i>.</p>\n";
}
Now this works well but if i want to add and and if condition like if the gender chosen on html form was F it would say "You are a little wannebe and a girl, get out of this site now!", i tried following:
if ($age <= 18 && $gender = F)...

if ($age <= 18) {etcetc}
elseif($gender = F) {etcetc}
and i also tried if condition inside of
if ($age <= 18) {
if($gender = F) {etcetc}
}
What is my mistake? How do i do that? Thanks from now.

Re: And If condition?

Posted: Wed Aug 12, 2009 7:55 pm
by requinix
What are you, like, 12?

Code: Select all

$gender = F
That assigns the value of the F constant to $gender.

Code: Select all

$gender == "F"
That compares $gender with the string "F".

Re: And If condition?

Posted: Wed Aug 12, 2009 8:24 pm
by rozkan
Well, i am not 12 but to be that rude and cranky you must be 80+. Thanks anyway gramma.