Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    New Coder
    Join Date
    Dec 2011
    Posts
    22
    Thanks
    2
    Thanked 0 Times in 0 Posts

    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

  • #2
    New to the CF scene
    Join Date
    Jun 2011
    Location
    USA/Kentucky
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #3
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    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
    Last edited by _Aerospace_Eng_; 01-11-2012 at 03:07 PM.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #4
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,642
    Thanks
    6
    Thanked 1,005 Times in 978 Posts
    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.

  • #5
    Senior Coder
    Join Date
    Aug 2006
    Posts
    1,234
    Thanks
    10
    Thanked 270 Times in 269 Posts
    By the way, your code is missing a right parenthesis, if that's at all relevant to your situation

    Code:
    if(var=="" || var2=="") {

  • #6
    Senior Coder
    Join Date
    Apr 2010
    Posts
    1,424
    Thanks
    70
    Thanked 102 Times in 101 Posts
    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 7 years. My business:
    American Made Signs

  • #7
    New Coder
    Join Date
    Dec 2011
    Posts
    22
    Thanks
    2
    Thanked 0 Times in 0 Posts
    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

  • #8
    Master Coder
    Join Date
    Apr 2003
    Location
    in my house
    Posts
    5,211
    Thanks
    39
    Thanked 201 Times in 197 Posts
    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

  • #9
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,642
    Thanks
    6
    Thanked 1,005 Times in 978 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •