Jump to content


Photo

Simple question


  • Please log in to reply
9 replies to this topic

#1 448191

448191
  • Staff Alumni
  • Advanced Member
  • 3,545 posts
  • LocationNetherlands

Posted 13 August 2006 - 09:02 AM

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.

#2 448191

448191
  • Staff Alumni
  • Advanced Member
  • 3,545 posts
  • LocationNetherlands

Posted 13 August 2006 - 09:10 AM

Wait a second? <<<EOF : "End Of File"?

How the *** does that work?

I clearly missed something basic here..  :-[

#3 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 13 August 2006 - 09:14 AM

example ok

echo <<<EOF
      <div id="main">
      {$j_main}
      </div><!--/main-->
    </div><!--/outer-->
  </body>
</html>
EOF;

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#4 448191

448191
  • Staff Alumni
  • Advanced Member
  • 3,545 posts
  • LocationNetherlands

Posted 13 August 2006 - 09:14 AM

Nevermind, I found it.

heredoc syntax

#5 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 13 August 2006 - 09:20 AM

does that mean according to that we can use anyold name like

<<<hithere

hithere;
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#6 448191

448191
  • Staff Alumni
  • Advanced Member
  • 3,545 posts
  • LocationNetherlands

Posted 13 August 2006 - 09:23 AM

I think it does:

Another way to delimit strings is by using heredoc syntax ("<<<"). One should provide an identifier 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. 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.



#7 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 13 August 2006 - 09:25 AM

can you give an example know why use it?

what to use it on?

so on please cheers.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#8 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 13 August 2006 - 09:29 AM

it's a short cut not to use the double quotes then?

<?php
$test=<<<eof
my name is redarrow
eof;
echo $test;
?>

Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc

#9 448191

448191
  • Staff Alumni
  • Advanced Member
  • 3,545 posts
  • LocationNetherlands

Posted 13 August 2006 - 09:33 AM

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?  ::))

#10 redarrow

redarrow
  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 13 August 2006 - 09:45 AM

sorry dont no but thank you for the explenation.
Wish i new all about php DAM i will have to learn
((EMAIL CODE THAT WORKS))
http://simpleforum.ath.cx/mail2.inc
((PAYPAL INTEGRATION THAT WORKS))
http://simpleforum.a...aypal1_info.inc




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users