SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Zealot karnetics's Avatar
    Join Date
    Dec 2004
    Location
    USA
    Posts
    179
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    what does the ! stand for in php

    I always seeing the ! in front of some commands.
    I would like to know what the ! stand for when used like that.
    example

    if (!isset($fname)) {....

    what does the ! stand for at the beginneing of isset()

  2. #2
    SitePoint Enthusiast
    Join Date
    Apr 2004
    Location
    Ireland
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    it stands for not, in this case if $fname is not set

  3. #3
    SitePoint Zealot karnetics's Avatar
    Join Date
    Dec 2004
    Location
    USA
    Posts
    179
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that is what I thought it stud for, but I wanted make sure..

  4. #4
    SitePoint Enthusiast JeroenvanP's Avatar
    Join Date
    Jan 2005
    Location
    L'dam-V'burg
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The ! is a logical operator, these are meant for simple equation-like statements (usually if/while/for-statements) like this:
    PHP Code:
    if ($brownie != 'cookie'
    (meaning "if $brownie does not equal 'cookie'")
    But can be used like this as well:
    PHP Code:
    if (!$brownie
    (meaning "if $brownie doesn't exist")

    Other logical operators are:

    == (equals)
    && (if both exist/are true)
    || (if one of both exist/are true)

    For more info check: http://www.php.net/manual/en/languag...rs.logical.php

  5. #5
    SitePoint Zealot karnetics's Avatar
    Join Date
    Dec 2004
    Location
    USA
    Posts
    179
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JeroenvanP
    The ! is a logical operator, these are meant for simple equation-like statements (usually if/while/for-statements) like this:
    PHP Code:
    if ($brownie != 'cookie'
    (meaning "if $brownie does not equal 'cookie'")
    But can be used like this as well:
    PHP Code:
    if (!$brownie
    (meaning "if $brownie doesn't exist")

    Other logical operators are:

    == (equals)
    && (if both exist/are true)
    || (if one of both exist/are true)

    For more info check: http://www.php.net/manual/en/languag...rs.logical.php

    thx for the tip

  6. #6
    SitePoint Evangelist
    Join Date
    May 2004
    Location
    Germany
    Posts
    550
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by JeroenvanP
    PHP Code:
    if (!$brownie
    (meaning "if $brownie doesn't exist")
    This also means "if $brownie is false", this will be true when $brownie is 0, false, '0' or an empty string (i think)


Bookmarks

Posting Permissions

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