473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

|| && ?

chunk1978
224 100+
it is proper syntax to use "||" and/or "&&" within PHP IF/ELSE statements like javascript?
Apr 11 '07 #1
3 2213
chunk1978
224 100+
here's an example of what i mean:

Expand|Select|Wrap|Line Numbers
  1. if    (($specifycountry != "Country0") || ($specifycountry != "Country44"))
  2.     {echo "$specifycountry<br>\n";}
  3.  
i'm asking this question because this statement doesn't seem to work because if "Country0" is selected, it will still echo the statement...

any ideas?
Apr 11 '07 #2
tolkienarda
316 100+
i took a php class a while back and all of that stuff was in our text books so i would and it is also in several tutorials i have read so i would assume that it is good programing practice. i've always thought the fewer if/else statements the better. i hate lots of code. if i can reduce lines i do

eric
Apr 11 '07 #3
code green
1,726 Expert 1GB
[PHP]if (($specifycountry != "Country0") || ($specifycountry != "Country44"))
{echo "$specifycountry<br>\n";} [/PHP]

i'm asking this question because this statement doesn't seem to work because if "Country0" is selected, it will still echo the statement...
Yes, and that is correct. The statement will print if either $specifycountry is not Country0 OR $specifycountry is not Country44. If you select Country0 it will fail the first condition but pass the second and so return TRUE. You need to study your BOOLEAN logic a little more.
Apr 12 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Thomas Scheffler | last post by:
Hi, I runned in trouble using XALAN for XSL-Transformation. The following snipplet show what I mean: <a href="http://blah.com/?test=test&amp;test2=test2">Test1&amp;</a> <a...
0
by: James Thurley | last post by:
I'm creating an XmlDocument manually, adding content using the Xml classes such as XmlElement and XmlText, and I then write it out as as "text/xml" to the HttpResponse.Output TextWriter object...
4
by: Luklrc | last post by:
Hi, I'm having to create a querysting with javascript. My problem is that javscript turns the "&" characher into "&amp;" when it gets used as a querystring in the url EG: ...
6
by: Rich Wallace | last post by:
All, I receive an xml doc with an element which contains a &amp; in the data. I am attempting to insert the data into a SQL Server database and I want to convert the &amp; to a "&" character before I...
8
by: Nathan Sokalski | last post by:
I add a JavaScript event handler to some of my Webcontrols using the Attributes.Add() method as follows: Dim jscode as String = "return (event.keyCode>=65&&event.keyCode<=90);"...
11
by: Jeremy | last post by:
How can one stop a browser from converting &amp; to & ? We have a textarea in our system wehre a user can type in some html code and have it saved to the database. When the data is retireved...
14
by: Arne | last post by:
A lot of Firefox users I know, says they have problems with validation where the ampersand sign has to be written as &amp; to be valid. I don't have Firefox my self and don't wont to install it only...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.