Go Back   CodingForums.com > :: Client side development > General web building

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-11-2012, 02:21 PM   PM User | #1
Blowpipe
New Coder

 
Join Date: Dec 2011
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
Blowpipe is an unknown quantity at this point
Meaning of || symbol

Hi there,

I am trying to find out what the meaning of || is and how I am able to write it up on my computer when writing function scripts.

I copied the symbol from another website and it is used in this context:

if(var=="" || var2=="" {
alert("something here");
return false
}else{
return true;
}

I haven't been able to find the meaning in any of my searches.

Thanks ahead of time

BP
Blowpipe is offline   Reply With Quote
Old 01-11-2012, 02:38 PM   PM User | #2
hershey.
New to the CF scene

 
Join Date: Jun 2011
Location: USA/Kentucky
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
hershey. is an unknown quantity at this point
Quote:
Originally Posted by Blowpipe View Post
Hi there,

I am trying to find out what the meaning of || is and how I am able to write it up on my computer when writing function scripts.

I copied the symbol from another website and it is used in this context:

if(var=="" || var2=="" {
alert("something here");
return false
}else{
return true;
}

I haven't been able to find the meaning in any of my searches.

Thanks ahead of time

BP
It's pretty much like saying "If the value of var = the value of var2."

The vertical bar is a simple that means to evaluate or equal to. There are different ways in PHP to call "equal to" functions, and that's one of them.
hershey. is offline   Reply With Quote
Old 01-11-2012, 03:05 PM   PM User | #3
_Aerospace_Eng_
Supreme Master coder!


 
_Aerospace_Eng_'s Avatar
 
Join Date: Dec 2004
Location: In a place far, far away...
Posts: 19,293
Thanks: 2
Thanked 1,044 Times in 1,020 Posts
_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light_Aerospace_Eng_ is a glorious beacon of light
Quote:
Originally Posted by hershey. View Post
It's pretty much like saying "If the value of var = the value of var2."

The vertical bar is a simple that means to evaluate or equal to. There are different ways in PHP to call "equal to" functions, and that's one of them.
What!? No the || is an OR logical operator. When you see in what you have there it means only one of the conditions needs to be true for that if statement to be true. To type that on your keyboard you use two pipes. It is usually the key under the backspace key, you may have to hit shift first to get it. It is also normally the backslash key.

http://www.w3schools.com/js/js_comparisons.asp
__________________
||||If you are getting paid to do a job, don't ask for help on it!||||

Last edited by _Aerospace_Eng_; 01-11-2012 at 03:07 PM..
_Aerospace_Eng_ is offline   Reply With Quote
Old 01-11-2012, 04:00 PM   PM User | #4
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,592
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Quote:
Originally Posted by _Aerospace_Eng_ View Post
It is usually the key under the backspace key, you may have to hit shift first to get it. It is also normally the backslash key.
Keep in mind that there are different keyboard layouts for different languages and operating systems. For me the vertical bar is on the “7” key (with forward slash on Shift) and I have to press Option (a. k. a. “Alt” with the Symbol ) + 7 to write it.
__________________
Don’t click this link!
VIPStephan is online now   Reply With Quote
Old 01-11-2012, 04:05 PM   PM User | #5
tracknut
Regular Coder

 
Join Date: Aug 2006
Posts: 891
Thanks: 4
Thanked 205 Times in 204 Posts
tracknut is an unknown quantity at this point
By the way, your code is missing a right parenthesis, if that's at all relevant to your situation

Code:
if(var=="" || var2=="") {
tracknut is offline   Reply With Quote
Old 01-11-2012, 04:32 PM   PM User | #6
myfayt
Senior Coder

 
Join Date: Apr 2010
Posts: 1,156
Thanks: 46
Thanked 95 Times in 94 Posts
myfayt can only hope to improve
It means OR. Your code should look like this in some cases,

PHP Code:
if ((var == "") || var2 == "") {
alert("something here");
}
else{
return 
true;

__________________
Been a sign maker for 5 years. My business:
American Made Signs
myfayt is offline   Reply With Quote
Old 01-12-2012, 11:03 AM   PM User | #7
Blowpipe
New Coder

 
Join Date: Dec 2011
Posts: 15
Thanks: 1
Thanked 0 Times in 0 Posts
Blowpipe is an unknown quantity at this point
Hi Everyone,

Thanks for the replies, it is good to know what that symbol on the keyboard meant and also what it means in terms of Javascript.

Thank you for those who pointed out my sloppy code - leaving a ) off, even though this was just an example to better explain my question, it shows I need to pay more attention to my writing.

Thanks one final time

BP
Blowpipe is offline   Reply With Quote
Old 01-12-2012, 07:15 PM   PM User | #8
bazz
Master Coder

 
Join Date: Apr 2003
Location: in my house
Posts: 5,211
Thanks: 39
Thanked 201 Times in 197 Posts
bazz will become famous soon enoughbazz will become famous soon enough
Stephan, you need a less complicated keyboard! lol

bazz
__________________
"The day you stop learning is the day you become obsolete"! - my late Dad.

Why do some people say "I don't know for sure"? If they don't know for sure then, they don't know!
Useful MySQL resource
Useful MySQL link
bazz is offline   Reply With Quote
Old 01-12-2012, 09:11 PM   PM User | #9
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,592
Thanks: 5
Thanked 865 Times in 842 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Quote:
Originally Posted by bazz View Post
Stephan, you need a less complicated keyboard! lol
Haha! Actually, typing special characters (for my German keyboard layout, e. g. like ç, ñ, ∂, µ, ™) is much simpler on Apple keyboards than on Windows/Unix type keyboards. These special characters are all on one of the regular keys and I only have to press Option or Shift+Option and the key rather than AltGr and some obscure code on the number block.
__________________
Don’t click this link!
VIPStephan is online now   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 09:37 AM.


Advertisement
Log in to turn off these ads.