Another simple question.

Discussion in 'PHP' started by x0x, Sep 21, 2008.

  1. #1
    $thing = 10

    if(thing>1) { blabla

    BUT what do we do with normal text?

    let's say $thing = 'i'm wathing you';

    I usually use if($thing) { blabla

    but if the $thing is just a empty space it will still {, but it shouldn't..

    I mean is there anything else I can use for text and if the variable is just a blank space, it should not work?

    So if $thing contains any characters other than whitespaces {...
     
    x0x, Sep 21, 2008 IP
  2. mwasif

    mwasif Active Member

    Messages:
    816
    Likes Received:
    23
    Best Answers:
    1
    Trophy Points:
    70
    #2
    Use trim() e.g.

    if(trim($thing))
     
    mwasif, Sep 21, 2008 IP
  3. x0x

    x0x Well-Known Member

    Messages:
    510
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #3
    Perfect. Thank you!
     
    x0x, Sep 21, 2008 IP
  4. ads2help

    ads2help Peon

    Messages:
    2,142
    Likes Received:
    67
    Best Answers:
    1
    Trophy Points:
    0
    #4
    I don't understand ?.?
     
    ads2help, Sep 21, 2008 IP
  5. redbayron2006

    redbayron2006 Active Member

    Messages:
    173
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #5
    I see that you have troubles with if statement. Dont mind there is one of the most simple commands in PHP. For your problem I think that !($thing) or isset() could help. Check Compare Alpha - Numeric Values With PHP and php.net for if statement here. Hope that helps
     
    redbayron2006, Sep 21, 2008 IP