#1
  1. No Profile Picture
    =) wannabe?
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 2002
    Location
    florida
    Posts
    2,153
    Rep Power
    19

    parse order question


    hello.

    in something like this
    PHP Code:
    $var = (isset($var)) ? 'hello' ''
    it'll check the isset() part first. right?

    i cant test it anytime soon


    thank you
  2. #2
  3. No Profile Picture
    Not there when you need me
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Oct 2001
    Location
    Berlin, Germany
    Posts
    1,430
    Rep Power
    18
    It'll evaluate like this:
    1. isset( $var ),
    2. 'hello' (or ''),
    3. =.
  4. #3
  5. No Profile Picture
    I AM A GOLDEN GOD
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Apr 2003
    Location
    Camarillo, California
    Posts
    5,929
    Rep Power
    1170
    That's a ternary operator, and yes, it evaluate the isset($var) portion. There is no other evaluation done.
  6. #4
  7. No Profile Picture
    I AM A GOLDEN GOD
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Apr 2003
    Location
    Camarillo, California
    Posts
    5,929
    Rep Power
    1170
    Hmm. Not sure what you mean by that realnowhere man; what that statement will do is evaluate if $var exists, (isset()) and if so, give it the value "hello". If not give it the value of ''. It's just a simplified if-else statement.
  8. #5
  9. No Profile Picture
    =) wannabe?
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 2002
    Location
    florida
    Posts
    2,153
    Rep Power
    19
    alrighty thanks. i just needed make sure. =)
  10. #6
  11. No Profile Picture
    Not there when you need me
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Oct 2001
    Location
    Berlin, Germany
    Posts
    1,430
    Rep Power
    18
    Yeah. However, isset( $var ), 'hello', '' and ... = ... are expressions, i. e. all of the following lines are valid PHP instructions:
    PHP Code:
    isset( $var );
    ( isset( 
    $var ) );
    'hello';
    '';
    ( isset( 
    $var ) ) ? 'hello' '';
    $var = ( isset( $var ) ) ? 'hello' ''
    And all but '' or 'hello' (depending on isset( $var )) are evaluated when the line is evaluated:
    Code:
    Let $var be set. I'm writing the whole thing in prefix notation to make it (less?) clear.
    
    evaluate( assign( '$var', ternary( ( isset( $var ) ), 'hello', '' ) ) ) ==>
    evaluate( assign( evaluate( '$var' ), evaluate( ternary( ( isset( $var ) ), 'hello', '' ) ) ) ) ==>
    evaluate( assign( evaluate( '$var' ), evaluate( ternary( evaluate( ( isset( $var ) ) ), evaluate( 'hello' ), evaluate( '' ) ) ) ) ) ==>
    evaluate( assign( evaluate( '$var' ), evaluate( ternary( evaluate( ( evaluate( isset( $var ) ) ), evaluate( 'hello' ), evaluate( '' ) ) ) ) )
    (No guarantee for correctness.)

IMN logo majestic logo threadwatch logo seochat tools logo