firewall Spyware removal internet speed test web security service free software and tips


Go Back   Web Security > Internet Security > Computer Help
FAQ Members List Search Today's Posts Mark Forums Read

Computer Help If you have a question about internet security / computer security, ask it here.

Advertisements

PHP NOT EQUAL

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-14-2008,
Senior Member
 
Join Date: Feb 2007
Posts: 360
Default PHP NOT EQUAL

Jim,
I'm working on some PHP code to try to do what I was saying, but I really don't know much PHP.

If this PHP code

if ($answer == "water")

means: if $answer = water, then how do you write if $answer doesn't = water?

Thanks Jim,

Roger
Reply With Quote
  #2 (permalink)  
Old 09-15-2008,
AMPC's Avatar
Administrator
 
Join Date: Jan 2007
Posts: 1,415
Default IF NOT Else PHP

Hi Roger,

In PHP a single equal sign is an assignment operator and used to assign a value to a variable. Two equal signs are a comparison operator, that is, it's used to compare two values. So, in this case, we use two equal signs to compare the two items: $answer and 'water'


<?
$answer = "water";
if($answer == "water")
echo "Water!";
else
echo "You need water!"
?>


or


<?
if($answer != "water")
echo "You need water!";
?>

Hope that helps
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is .


Powered by a CPU
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.3.2 © 2009, Crawlability, Inc.