And If condition?

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
rozkan
Forum Newbie
Posts: 10
Joined: Thu Jul 02, 2009 8:08 pm

And If condition?

Post 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.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: And If condition?

Post 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".
rozkan
Forum Newbie
Posts: 10
Joined: Thu Jul 02, 2009 8:08 pm

Re: And If condition?

Post by rozkan »

Well, i am not 12 but to be that rude and cranky you must be 80+. Thanks anyway gramma.
Post Reply