Results 1 to 2 of 2

Thread: What is this ?false:true thing?

  1. #1
    Join Date
    Jun 2006
    Under your bed

    What is this ?false:true thing?

    Look at this code:

    PHP Code:
    $resolve='whatever you want to put here';

    if (
    $resolve = (preg_match('/false|no|off/i'$resolve))?false:true;

    If I var_dump $resolve after this, and it contains the word "false", "no" and/or "off" I get bool(false) Otherwise I get bool(true). How exactly is it doing that, though? What role does "?false:true" play in this?

    I want to know what this is, it looks handy.
    Last edited by evenstar7139; 07-25-2012 at 11:37 PM.
    The better I get at programming, the more I appreciate arrays. Handy dandy things they are.

  2. #2
    Join Date
    Aug 2004
    ternary operator

    PS: Please use with moderation, saving it for simple usages where it's easy to read. For more complex cases, a standard and indented if/else block will make your life easier when maintaining your code in the future.
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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