448191 Posted August 13, 2006 Share Posted August 13, 2006 I've got a simple question (Yes, I do those too :P).What was that thing again, whatsjemecallit, you use so you can use both single and double qoutes without having to escape them?Something like EO>>? A link explaining what it is would be nice also. Quote Link to comment Share on other sites More sharing options...
448191 Posted August 13, 2006 Author Share Posted August 13, 2006 Wait a second? <<<EOF : "End Of File"?How the *** does that work?I clearly missed something basic here.. :-[ Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 13, 2006 Share Posted August 13, 2006 example ok[code]echo <<<EOF <div id="main"> {$j_main} </div><!--/main--> </div><!--/outer--> </body></html>EOF;[/code] Quote Link to comment Share on other sites More sharing options...
448191 Posted August 13, 2006 Author Share Posted August 13, 2006 Nevermind, I found it.[url=http://nl2.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc]heredoc syntax[/url] Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 13, 2006 Share Posted August 13, 2006 does that mean according to that we can use anyold name like<<<hitherehithere; Quote Link to comment Share on other sites More sharing options...
448191 Posted August 13, 2006 Author Share Posted August 13, 2006 I think it does:[quote=php.net]Another way to delimit strings is by using heredoc syntax ("<<<"). [b]One should provide an identifier[/b] after <<<, then the string, and then the same identifier to close the quotation.The closing identifier must begin in the first column of the line. [b]Also, the identifier used must follow the same naming rules as any other label in PHP: it must contain only alphanumeric characters and underscores, and must start with a non-digit character or underscore. [/b][/quote] Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 13, 2006 Share Posted August 13, 2006 can you give an example know why use it?what to use it on?so on please cheers. Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 13, 2006 Share Posted August 13, 2006 it's a short cut not to use the double quotes then?[code]<?php$test=<<<eofmy name is redarroweof;echo $test;?>[/code] Quote Link to comment Share on other sites More sharing options...
448191 Posted August 13, 2006 Author Share Posted August 13, 2006 Sort of. It behaves identically to double quotes(ie expands variables), but you don't actually use double double quotes, so you can include double quotes in the string without having to escape them.To bad there isn't an equivalent that mimics single quotes, since that's what I'd prefer. (or is there? ::)) Quote Link to comment Share on other sites More sharing options...
redarrow Posted August 13, 2006 Share Posted August 13, 2006 sorry dont no but thank you for the explenation. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.