SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict cranjled's Avatar
    Join Date
    Apr 2004
    Location
    ny
    Posts
    382
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Any info on print <<<BLOCK...BLOCK;

    I like to use single quotes when echoing something so I don't have to look at the backslashes in HTML attributes. I recently came across this method of doing it, which seems to eliminate the echo statments, single-quotes, and backslashes...and was wondering if this is deprecated, not fully supported or what's the story on it?

    Any insight is appreciated,

    Thanks

    Code:
    print <<<BLOCK
    <form method="post" action="{$_SERVER['PHP_SELF']}">
    <input type="text" name="SomeVar" value="{$_POST['someVar']}" />
    <input type="submit" name="submit" value="submit" />
    </form>
    BLOCK;

  2. #2
    SitePoint Addict launchcode's Avatar
    Join Date
    Dec 2004
    Location
    Bristol, UK
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's called the heredoc method. Personally I would use echo <<<MARKER and not print, but it doesn't matter too much.

    You can find plenty of info on heredoc in the php manual, specifically in the strings section.

    It is most certainly not depreciated (and I doubt ever will be) and is fully supported by all versions of PHP since.. well.. heck of a long time!

    Cheers,

    Rich
    Richard Davey

    Launchcode
    PHP Security Guide. Think your scripts are secure? Think again.

  3. #3
    SitePoint Addict cranjled's Avatar
    Join Date
    Apr 2004
    Location
    ny
    Posts
    382
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks...very helpful.

  4. #4
    SitePoint Zealot
    Join Date
    Oct 2002
    Posts
    146
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I found it dead useful to catch cpanel output in PHP - cpanel gets parsed first and you can never be sure whether there'll be quotes in it.

    Amorya
    KickRSS - free web-based RSS aggregator.


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
  •