1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

'?' in php

Discussion in 'PHP' started by 1jen, Jun 5, 2011.

  1. #1
    isset($_COOKIE[""])) ? $_COOKIE[""]+2 : 0;

    Can others please translate what this says? I don't know what '?' question mark with this means in PHP. Thanks a lot.
     
    1jen, Jun 5, 2011 IP
  2. 1jen

    1jen Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I know this is, isset($_COOKIE[""])) check to see if cookie is set.

    I don't know what the rest of this with it means after searching everywhere. Thank you.
     
    1jen, Jun 5, 2011 IP
  3. kasun0777

    kasun0777 Well-Known Member

    Messages:
    355
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    138
    #3
    check again your code. i think no "?" in this coding. and this is wrong
     
    kasun0777, Jun 5, 2011 IP
  4. 1jen

    1jen Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    isset($_COOKIE[""])) ? $_COOKIE[""]+2 : 0;
    PHP:
    All I said was what does this mean? It does something, I just want to know what it means by you that know PHP code. Because I'm trying to understand what it means so I know if I still need it. I'm only asking something easy, what does it mean? Thank you very much for your help.
     
    1jen, Jun 6, 2011 IP
  5. wmtips

    wmtips Well-Known Member

    Messages:
    601
    Likes Received:
    70
    Best Answers:
    1
    Trophy Points:
    150
    #5
    wmtips, Jun 6, 2011 IP
  6. SiJz

    SiJz Peon

    Messages:
    51
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hi,

    When you're not used to it, it can look quite odd..

    using this code as an example:
    
    $var = "";
    echo (trim($var)=="") ? "empty" : "not empty";
    $var = "a";
    echo (trim($var)=="") ? "empty" : "not empty";
    
    Code (markup):
    basically on the first pass, the $var is empty, the echo will output 'empty', on the next one it will output 'not empty'
    thats a really simple view, it can be used for more complex functionality, as per your sample.

    in your sample, there would be a cookie name in the double quotes that you've removed, lets call it VisitorCount for this example.

    Assuming that the cookie has never been set, so perhaps a first visit
    -> then 0 will be used or returned, depending upon the earlier part of the line that not shown.

    Ok, assuming that the cookie is already set, so perhaps a returning visit, say it has a value of 9
    -> then the value used or returned would be cookie-value+2, so 11

    Hope that helps?

    Si
     
    SiJz, Jun 6, 2011 IP