The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.
|
 |
|
Dev Shed Forums
> Programming Languages
> PHP Development
|
Are there "Here" documents for PHP?
Discuss Are there "Here" documents for PHP? in the PHP Development forum on Dev Shed. Are there "Here" documents for PHP? PHP Development forum discussing coding practices, tips on PHP, and other PHP-related topics. PHP is an open source scripting language that has taken the web development industry by storm.
|
|
 |
|
|
|
|

Dev Shed Forums Sponsor:
|
|
|

April 10th, 2000, 12:42 AM
|
 |
Contributing User
|
|
|
|
|
Hi,
I'm new to PHP, so maybe I've simply
overlooked the obvious, but I was wondering
if PHP supports "Here" documents (like perl,
or UNIX shell). Any help would be greatly
appreciated! I hate having to all the
quotes in my HTML. =)
Scott
|

April 10th, 2000, 09:27 PM
|
|
Contributing User
|
|
Join Date: Apr 2000
Posts: 31
Time spent in forums: < 1 sec
Reputation Power: 14
|
|
I have no idea what you mean by "Here"-documents.. But I hope "having to " ment something even close to this:
In perl (it's been some time so forgive me for minor errors  :
print "Bla?";
print <<EOF
<html>blablahHTML here
<a href="http://your_link_here">Hmm.</a>
</html>
EOF
In PHP:
print "Bla?";
?><html>blablahHTML here
<a href="http://your_link_here">Hmm.</a>
</html>
<?
|

April 11th, 2000, 01:05 PM
|
 |
Contributing User
|
|
|
|
|
It looks like you're saying that if I want
to have large chunks of HTML code without
having to the quotes, I should just put
the HTML outside of the <? ?> tags.
There are two reasons that I wanted to have
all of my HTML within the PHP.
(1) I believe that my pages will execute
faster if they are entirely contained within
the PHP tags (rather than switching back
and forth)
(2) In perl you can embed variables in the
HTML contained in a Here document and I was
hoping that PHP could do the same.
Thanks for your help. =)
Scott
|

April 12th, 2000, 07:01 PM
|
|
Contributing User
|
|
Join Date: Apr 2000
Posts: 31
Time spent in forums: < 1 sec
Reputation Power: 14
|
|
You can do (almost like in perl) templates like this:
while($row=something("  ")) {
<?
Name: <? echo $row["name"] ?><br>
Address: <? echo $row["address"] ?><br>
<p>
?>
}
|

April 12th, 2000, 08:11 PM
|
|
Junior Member
|
|
Join Date: Apr 2000
Posts: 8
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
here
<<<ENDH
endh can be any combination of characters which are not in the here document.
ENDH;
|

April 13th, 2000, 04:20 AM
|
 |
Contributing User
|
|
Join Date: Feb 2000
Location: Perth West Australia
Posts: 757
Time spent in forums: 4 h 18 m 32 sec
Reputation Power: 14
|
|
|
believe it or believe it not - you code gets parsed faster if you keep your <?php to a minimum - jumping in and out of php does not make things any slower - on larger files just the opposite.
------------------
Simon Wheeler
FirePages -DHTML/PHP/MySQL
|

April 13th, 2000, 11:52 AM
|
 |
Contributing User
|
|
|
|
|
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by firepages:
believe it or believe it not - you code gets parsed faster if you keep your <?php to a minimum - jumping in and out of php does not make things any slower - on larger files just the opposite.
[/quote]
That's what I get for listening to those
NT/ASP guys! Thanks for the tip.
Scott
|

April 13th, 2000, 11:54 AM
|
 |
Contributing User
|
|
|
|
<BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by geosync:
here 
<<<ENDH
endh can be any combination of characters which are not in the here document.
ENDH;[/quote]
Thanks! I'll give it a try.
Scott
|
Developer Shed Advertisers and Affiliates
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|