Not signed in (Sign In)

Categories

Vanilla 1.1.1 is a product of Lussumo. More Information: Documentation, Community Support.

    •  
      CommentAuthorachraf
    • CommentTimeJan 27th 2007
     permalink

    try to do this in php code :

    echo <<<END demo text END;

    screenshot

  1.  permalink

    Is it okay with heredoc that the END; is not at the start of the line actually? When you delete the whitespace before the END; the highlighting is okay.

    • CommentAuthori
    • CommentTimeJan 27th 2007 edited
     permalink

    As far as I know… PHP will not consider that END; as a closing identifier if there are other characters in front.

    Edit: “That means especially that the identifier may not be indented”, look in the PHP manual on heredoc syntax in the Warning box.

  2.  permalink

    So it is not a bug then :)

    • CommentAuthorBrendonKoz
    • CommentTimeJan 27th 2007 edited
     permalink

    No, it is not a bug. idyllrain is correct in assuming that the HEREDOC statement style requires the ending delimiter to be on its own line with absolutely nothing (no whitespace) appearing to the left. This applies to both PHP and Perl (and perhaps any other language that uses the syntax).

    Furthermore, any whitespace prior to the actual code being sent to standard output will also be included…therefore, all code after the initial echo and desired delimiter should probably be forced to the utmost left (without automatic spacing). Therefore…is it possible for a snippet to override the default indentation within Intype?

    •  
      CommentAuthortstrokes
    • CommentTimeJan 27th 2007
     permalink

    Same in ruby too. I think heredocs are pretty standard across the board.

    •  
      CommentAuthoryarden
    • CommentTimeJan 28th 2007
     permalink
    then why in the echo manual its different?
    http://il2.php.net/echo
    • CommentAuthori
    • CommentTimeJan 28th 2007 edited
     permalink

    Different? How so? The example uses the correct syntax (the one we’ve been discussing above):

    echo <<<END This uses the "here document" syntax to output multiple lines with $variable interpolation. Note that the here document terminator must appear on a line with just a semicolon. no extra whitespace! END;

    :-/

    • CommentAuthorsvenax
    • CommentTimeJan 28th 2007
     permalink

    yarden: then why in the echo manual its different?
    http://il2.php.net/echo

    What is different? In that example the heredoc END marker is not indented. Most languages that has heredocs (PHP, Perl) requires the end marker to start at column zero. Ruby does allow the marker to be indented using a special syntax, e.g.
    puts <<END stuff END

    versus

    puts <<-END stuff END

    •  
      CommentAuthoryarden
    • CommentTimeJan 28th 2007
     permalink
    the highlighting is not okay in intype or php site?
    • CommentAuthorsvenax
    • CommentTimeJan 28th 2007
     permalink

    The highlighting is OK both in Intype and on the PHP site.

    •  
      CommentAuthoryarden
    • CommentTimeJan 28th 2007 edited
     permalink
    your right, my bad
    •  
      CommentAuthorachraf
    • CommentTimeJan 28th 2007
     permalink

    your right, we need to remove white space before END;

    screenshot