SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2012
    Location
    California
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    heredoc string not working

    I copied this example straight out a PHP book I'm currently reading. I've also looked at php.net to verify the syntax but could not see any differences. I use Aptana Studio 3, PHP 5.3.13 through WAMP , and I tested it in both Chrome and Firefox on Windows 7.

    PHP Code:
    <?php
    $tobeornottobe 
    = <<<_EOT
    To be, or not to be, that is the question:
    Whether 'tis Nobler in the mind to suffer
    The Slings and Arrows of outrageous Fortune,
    Or to take Arms against a Sea of troubles,
    And by opposing end them: to die, to sleep
    _EOT;

    echo 
    $tobeornottobe;
    ?>
    Aptana seems to think that 'tis is the beginning of the string because of the single quotation mark. It also marks the line that ?> is on as a syntax error. Any thoughts?

    Thanks!

  2. #2
    Foozle Reducer ServerStorm's Avatar
    Join Date
    Feb 2005
    Location
    Burlington, Canada
    Posts
    2,699
    Mentioned
    89 Post(s)
    Tagged
    6 Thread(s)
    Try putting an extra space before the herdoc terminator and see if that works?

    PHP Code:
    <?php
    $tobeornottobe 
    = <<<_EOT
    To be, or not to be, that is the question:
    Whether 'tis Nobler in the mind to suffer
    The Slings and Arrows of outrageous Fortune,
    Or to take Arms against a Sea of troubles,
    And by opposing end them: to die, to sleep

    _EOT;

    echo 
    $tobeornottobe;
    ?>
    ictus==""

  3. #3
    SitePoint Wizard bronze trophy Jeff Mott's Avatar
    Join Date
    Jul 2009
    Posts
    1,264
    Mentioned
    18 Post(s)
    Tagged
    0 Thread(s)
    Make sure there's no whitespace at the end of <<<_EOT. The identifier must be followed immediately by a newline.
    "First make it work. Then make it better."


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
  •