3 ms·
> PHP is still the only language that assumes HTML output by default. For me, that's not a feature, it's an oddity that I have to work around. I guess it's a f
by Joeboy 13y ago
> PHP is still the only language that assumes HTML output by default.
For me, that's not a feature, it's an oddity that I have to work around. I guess it's a feature if you're using PHP as the HTML template language it was designed to be, but I suspect that's a minority use case these days.
- nodata 13y agoBut that's what it was designed for..
- 616c 13y ago> For me, that's not a feature, it's an oddity that I have to work around. Well, I would venture a guess that you should have looked up the language's name and its meaning, then the entire focus of PHP might not come as much of a surprise.
- rbanffy 13y ago"Personal Home Page"?
- gnerd 13y ago> Zeev Suraski and Andi Gutmans rewrote the parser in 1997 and formed the base of PHP 3, changing the language's name to the recursive acronym PHP: Hypertext Preprocessor. http://en.wikipedia.org/wiki/Php#History http://en.wikipedia.org/wiki/Php#History
- 616c 13y agoYes, to get back to my point, it is basically a templating language for HTML, hence the hypertext. I think the name made it clear being ambitious with it outside of HTML was going to be difficult, unless you like the challenge of making cars into airplanes, and submarines in to hang-gliders.
- tudborg 13y agoHow is the default header of `Content-Type: text/html` Any different form a default header of `Content-Type: text/plain`? It takes you about 3-4 seconds to change it for your entire project.
- Joeboy 13y agoThat's not what I mean, and I don't think it's what the person I replied to meant either. I assume text/html is the default content type for all web frameworks. I was referring to the fact that the first thing pretty much all PHP apps do is say "Wait! Don't output anything yet! I have code to run!". I believe modern PHP frameworks generally borrow the controller/template pattern from other languages, because it generally makes more sense than PHP's default of outputting HTML unless told otherwise.
- sbarre 13y agoI would actually argue that using PHP as the templating language in a PHP MVC application has become the majority use case. Why layer an additional templating language (Smarty, etc) on top of PHP - incurring extra processing and parsing - when PHP is a perfectly capable templating language itself? There are cases where you may need to do this (if you can't "trust" the templates for example and you need to enforce some kind of validations or restrictions on them) but otherwise you just need to follow/enforce business rules about what can go in your views, and just use plain ol' PHP..
- Joeboy 13y agoI actually agree with you. It's been a while since I used PHP much, but the last time I did some work in, erm, I think it was Symfony, I remember thinking that PHP was pretty nice for the template layer. That may partly be because I'd got used to Django, which had an aggressively simplistic template layer at the time. Edit: By which I mean, Symfony improves things by working around PHP's suboptimal default.
- Kudos 13y ago> Why layer an additional templating language (Smarty, etc) on top of PHP - incurring extra processing and parsing - when PHP is a perfectly capable templating language itself? From past experience: to stop shittier developers at your company putting controller logic in the templates. Using something that does nothing but templating ensures that your templates do nothing but present data.
- sbarre 13y agoI addressed that in my post actually. If you have shitty developers in your company who can't follow business rules, PHP isn't your problem.
- krapp 13y agoWith templating systems which 'compile' templates down to php anyway, that might be a distinction without a difference.