Results 1 to 6 of 6

Thread: variables in heredoc

Threaded View

  1. #1

    Thread Starter
    Frenzied Member StrangerInBeijing's Avatar
    Join Date
    Mar 2005
    Location
    Not in Beijing
    Posts
    1,666

    Resolved variables in heredoc

    I just started using this heredoc syntax after reading about it. Pretty handy and easy to use.
    One thing I dont understand though.
    The following will fail:
    Code:
    $ret_val = <<<EOT
            $_SESSION['usr_sal'];
    EOT;
    With a
    Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING
    error.
    However, this will work fine:
    Code:
    $var = $_SESSION['usr_sal'];
          $ret_val = <<<EOT
            $var
    EOT;
    I dont get it...both are essentially the same thing, or not?
    The same thing goes for constants I defined in included files.
    Last edited by StrangerInBeijing; Nov 22nd, 2007 at 09:21 AM. Reason: Resolved

Posting Permissions

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



Click Here to Expand Forum to Full Width