If statement in Php code

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
daisy4u721
Forum Newbie
Posts: 1
Joined: Tue Feb 03, 2009 9:28 am

If statement in Php code

Post by daisy4u721 »

How do i write a php code that emails an evaluation to me if Q8 is a Yes.
I tried this But it didn't work, any help please I'm totally new to this
if ($Q8) == Yes)
{
$sendMailTo .= "1234@yahoo.com";
}
mickeyunderscore
Forum Contributor
Posts: 129
Joined: Sat Jan 31, 2009 9:00 am
Location: UK

Re: If statement in Php code

Post by mickeyunderscore »

Code: Select all

if ($Q8 == 'Yes')
{
     $sendMailTo .= "1234@yahoo.com";
}
User avatar
Skoalbasher
Forum Contributor
Posts: 147
Joined: Thu Feb 07, 2008 8:09 pm

Re: If statement in Php code

Post by Skoalbasher »

Even faster, make Q8 a bool

Code: Select all

 
if ($Q8)
{
     $sendMailTo .= "1234@yahoo.com";
}
 
Lol. It's a LOT less code.. 8O
User avatar
Ziq
Forum Contributor
Posts: 194
Joined: Mon Aug 25, 2008 12:43 am
Location: Russia, Voronezh

Re: If statement in Php code

Post by Ziq »

This if statement will be generate an E_NOTICE error if $Q8 is undefined. Better use empty() or isset() functions.
Post Reply