SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: echo <<?

  1. #1
    SitePoint Wizard lukeurtnowski's Avatar
    Join Date
    Mar 2003
    Location
    Coronado
    Posts
    1,665
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    echo <<?

    How do I echo a lot of html code, I thought there was a function like
    PHP Code:
    echo >>end
    ...
    ...
    html code
    ...
    ...
    end
    to output html without worrying about quotes and semicolons all the time
    "Oh, and Jenkins--apparently your mother died this morning."

  2. #2
    SitePoint Addict
    Join Date
    Feb 2003
    Location
    Shropshire
    Posts
    203
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not something I tend to use or have used for a long time, but I think what you need is
    PHP Code:
    echo <<<__HTML_END
    <!-- HTML here -->
    __HTML_END; 

  3. #3
    From space with love silver trophy
    SpacePhoenix's Avatar
    Join Date
    May 2007
    Location
    Poole, UK
    Posts
    5,072
    Mentioned
    103 Post(s)
    Tagged
    0 Thread(s)
    You're thinking of Heredoc. You need to remember with heredoc that the opening and closing "tags" can't be indented at all.l
    Community Team Advisor
    Forum Guidelines: Posting FAQ Signatures FAQ Self Promotion FAQ
    Help the Mods: What's Fluff? Report Fluff/Spam to a Moderator

  4. #4
    SitePoint Addict bronze trophy vectorialpx's Avatar
    Join Date
    Dec 2012
    Location
    Bucharest
    Posts
    247
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Also
    Code:
    <?php
    echo <<<FOOBAR
    Hello World!
    FOOBAR;
    ?>
    is the same with
    Code:
    <?php
    echo <<<"FOOBAR"
    Hello World!
    FOOBAR;
    ?>
    but not with
    Code:
    <?php
    echo <<<'FOOBAR'
    Hello World!
    FOOBAR;
    ?>
    if you need variables into your text.

  5. #5
    Always A Novice bronze trophy
    K. Wolfe's Avatar
    Join Date
    Nov 2003
    Location
    Columbus, OH
    Posts
    2,182
    Mentioned
    67 Post(s)
    Tagged
    2 Thread(s)
    Much easier to flip around the other way and use <?php ?> when you need to do something

  6. #6
    SitePoint Wizard lukeurtnowski's Avatar
    Join Date
    Mar 2003
    Location
    Coronado
    Posts
    1,665
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    ok, thanks
    "Oh, and Jenkins--apparently your mother died this morning."


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
  •