Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IF && !=

Status
Not open for further replies.

kpdvx

Programmer
Dec 1, 2001
87
US
this works:
if ($intNumber % 2 == 0)

but this doesnt:
if ($intNumber % 2 == 0) && ($intNumber != 7)

any ideas why?
 
if ($intNumber % 2 == 0) && ($intNumber != 7)

If works like this:

If (condition)
block of commands
[elseif (condition)
block of commands]
[else
block of commands]

The round parentisis are mandatory. inside square parentises are optional fields.

Your error was that the parentises you opened for the condition you closed in the middle of the condition.

Another thing, you should place parentises just to improve the reading of the code, so i suggest you to use this:
if ((($intNumber % 2) == 0) && ($intNumber != 7))



Anikin
Hugo Alexandre Dias
Web-Programmer
anikin@ip.pt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top