Whats with HEREDOC all of a sudden?

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply

Do you use HEREDOC?

Yes, i use it all the time
4
33%
No, i jump in and out of PHP
5
42%
Depends on the project
3
25%
 
Total votes: 12

User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Whats with HEREDOC all of a sudden?

Post by JayBird »

I've noticed more use of HEREDOC (especially by Nay). Personally i never use it, i prefer to jump in an out of php and leave my HTML separate.

Just wondering everyone elses thoughts.

Thanks

Mark
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

i try not to leave php, but when it comes to big chunks of html or a part where there is no php code at all then i just switch over to HTML "mode".
Stoneguard
Forum Contributor
Posts: 101
Joined: Wed Aug 13, 2003 9:02 pm
Location: USA

Post by Stoneguard »

Actually I tend to use heredoc style for things like long queries joining a lot of tables together. I still mix my php and HTML, though I try to keep all my solid functions up ahead of HTML and then just use PHP to format my output.
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

As I mentioned in another thread; never heredoc. I find it more readable by jumping in and out of php (abit un-logical, but...).
Nay
Forum Regular
Posts: 951
Joined: Fri Jun 20, 2003 11:03 am
Location: Brisbane, Australia

Post by Nay »

whooohoo!

Well, I feel guilty when I leave PHP :(. I never use the ?> until the end :lol:. Well, it's just me. I don't like going in and out, I don't have a problem debugging or writing longer, as long as I don't have to exit ?>.

It's all about preference actually....

imho, heredoc is the cleverest thing PHP has ever done :lol: haha....

well, maybe now 8-)

-Nay
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post by JayBird »

Perl was cleverer!

you could do this

Code: Select all

$lots_of_html = qq~anything you want here - !"(*$&^&!"$*%~;
you could actually choose the symbol you wanted to use instead of the double quotes. I always used the Tilde (~) as HTML nearly never uses this symbol.

If it was like this in PHP maybe i would use it more.

Mark

It didn't matter if th
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

some of my tools fail on debugging when it comes to heredoc, therefor I seldom use it ;)
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

I almost always use heredoc for HTML because I find it easier to read especially when there's HTML in loops. I don't like having:

Code: Select all

<?php
}
?>
It's one of those personal preference things really...

Mac
User avatar
Kriek
Forum Contributor
Posts: 238
Joined: Wed May 29, 2002 3:46 am
Location: Florida
Contact:

Post by Kriek »

Kriek -> Steeplechaser

Inline HTML ninety-nine percent of the time.
murph
Forum Commoner
Posts: 29
Joined: Fri Oct 03, 2003 1:28 pm
Location: washington

Post by murph »

i use heredoc because of a function i have that will parse through the

Code: Select all

$blah =<<<EOT;
<html>{var}</html>
EOT;
and replace all the array keys with the array values. Its one of the best functions i have ever found. Now i didnt write this function. I believe that Celerondude did but im not too sure on that. it works so well i can always find a use for it no matter what script im writing
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

I wouldn't use either method: instead, I'd include an html file.
Post Reply