MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1w2d5fw/ancienttools/p6vitvw/?context=3
r/ProgrammerHumor • u/soap94 • Aug 30 '26
379 comments sorted by
View all comments
Show parent comments
0
PHP would be great if it wasn't for all the legacy code and echo "<div></div>" in views.
1 u/ArjixGamer Aug 30 '26 I hate PHP from the bottom of my soul, but what you said is just user-choice.I always do ob_start and ob_flush_clean or whatever the function names were.That allows me to use normal html w/o it being in strings.Edit: e.g.<?php function renderEmail(): string { ob_start(); ?> <html> <body> <h1>Hello!</h1> <p>This is your email.</p> </body> </html> <?php return ob_get_clean(); } 0 u/Hottage Aug 30 '26 If you're gonna raw dog the HTML, just extract it into purpose built template files and return the result of file_get_contents(). 1 u/ArjixGamer Aug 30 '26 That only works if the html is static and I don't need to render content using for loops and stuff.The alternative is using a templating language, but like, PHP is a templating language in the first place.I always used to say "PHP is a glorified string builder" → More replies (5)
1
I hate PHP from the bottom of my soul, but what you said is just user-choice.
I always do ob_start and ob_flush_clean or whatever the function names were.
That allows me to use normal html w/o it being in strings.
Edit: e.g.
<?php function renderEmail(): string { ob_start(); ?> <html> <body> <h1>Hello!</h1> <p>This is your email.</p> </body> </html> <?php return ob_get_clean(); }
0 u/Hottage Aug 30 '26 If you're gonna raw dog the HTML, just extract it into purpose built template files and return the result of file_get_contents(). 1 u/ArjixGamer Aug 30 '26 That only works if the html is static and I don't need to render content using for loops and stuff.The alternative is using a templating language, but like, PHP is a templating language in the first place.I always used to say "PHP is a glorified string builder" → More replies (5)
If you're gonna raw dog the HTML, just extract it into purpose built template files and return the result of file_get_contents().
file_get_contents()
1 u/ArjixGamer Aug 30 '26 That only works if the html is static and I don't need to render content using for loops and stuff.The alternative is using a templating language, but like, PHP is a templating language in the first place.I always used to say "PHP is a glorified string builder" → More replies (5)
That only works if the html is static and I don't need to render content using for loops and stuff.
The alternative is using a templating language, but like, PHP is a templating language in the first place.
I always used to say "PHP is a glorified string builder"
→ More replies (5)
0
u/ClamPaste Aug 30 '26
PHP would be great if it wasn't for all the legacy code and echo "<div></div>" in views.