Live data from Hacker News

I Like PHP

beust.com

151–160 of 269 posts

Re: I Like PHP

#151
post #122

Earlier quoted context omitted.

This mind-bendingly important. In 1999, you could download one single installer on Windows, run it and with literally no further configuration you'd be writing PHP on an Apache/MySQL stack. No other environment even came close at the time and for a long time following.

This is still the main reason why I use PHP: the development cycle is just so fast, and if you are experienced enough to write good code without anyone holding your hand, you can do great work in PHP in a much shorter period of time when compared to most other platforms (at least the ones I've tried). When people criticise the PHP language I think they really miss the point: it is the PHP platform that is really powe…

Yep. And compared to Rails, something like mod_php is just so much faster and less resource hungry, it hurts. I use both regularly in production, and scaling the PHP side is almost trivial compared to the rails side.

Re: I Like PHP

#152
post #97
post #42

me too, i like php. it's a decent templating language with some very advanced features. it even supports namespaces!

It's an XSS-prone templating language, as the default correct syntax for outputting variables is: which is far from encouraging safe best practices. PHP namespaces aren't any better: http://pornel.net/phpns

Actually, you should also always indicate the character encoding, for reasons I explain here:

http://shiflett.org/blog/2005/dec/google-xss-example

Re: I Like PHP

#153
post #122

Earlier quoted context omitted.

This mind-bendingly important. In 1999, you could download one single installer on Windows, run it and with literally no further configuration you'd be writing PHP on an Apache/MySQL stack. No other environment even came close at the time and for a long time following.

This is still the main reason why I use PHP: the development cycle is just so fast, and if you are experienced enough to write good code without anyone holding your hand, you can do great work in PHP in a much shorter period of time when compared to most other platforms (at least the ones I've tried). When people criticise the PHP language I think they really miss the point: it is the PHP platform that is really powe…

As someone learning, I figured out pretty quickly from many forum threads about this topic, that I was simply too ignorant to be confident in writing solid PHP. I am in no rush to do anything useful (just having fun), and I'm trying to concurrently learn Vim and Git. so I chose Python. I might try PHP, if I ever feel I have learned to write OO code competently.

tl;dr: Too many gotchyas for a beginner. I need discipline imposed on me when I'm learning, ymmv.

Re: I Like PHP

#154
post #55

Earlier quoted context omitted.

Wow, It's pretty apparent that there are a lot of young programmers here on HN. I was just stating my opinion and I got downvoted because I talked bad about your precious frameworks.

Comments, Item 8: http://ycombinator.com/newsguidelines.html

guess what? You aren't going to stop me from my opinion, sorry. You sure as hell aren't stopping the mass amounts of people from down voting my above comments for merely stating my opinion on frameworks.

oh and btw, my point has pretty much been proven.

Re: I Like PHP

#155
post #133

Earlier quoted context omitted.

Of course it is impossible to do dynamic web pages without mixing code and markup, don't let anyone tell you otherwise. It's just that in PHP it is possible to one single file that is both code and markup combined, whereas other languages require a separate logic file that sends data to templates.

That is NOT a result of the language. It is trivial in any language to combine both code and markup. However people using other languages generally work to avoid that. That said, there is a long-standing tension between keeping logic out of templates, and giving templates more flexibility. Different frameworks take different positions on how to draw the line. PHP can be seen as an extreme position towards giving temp…

> That is NOT a result of the language.

Considering PHP is more-or-less designed to be a templating language, I'd say it is. Partly.

On the other hand, PHP is a pretty good templating language. People should just learn to separate business logic from presentation logic.

Re: I Like PHP

#156
post #113
post #89

Earlier quoted context omitted.

This is unfortunately true. I'm a PHP programmer (currently writing a book, A Highly Negative Book About PHP , that I've been billing as "like Essential Java but tells you what not to do") and, I like to think, a fairly good one; reading this article made me cringe because this guy is emblematic of most of the problems in the PHP community. He: -accepts uncritically gobs of code dredged up via Google -considers somet…

I'm convinced that this post is satire and the author has trolled us all. In fact, i reject any other explaination. Sticks fingers in ears . Lalalalala, it's satire, nobody is this incompetent. Lalalalala, can't hear you.

The best one has to be running your site from a git repo.

I'm not sure why running old code on an old server that has support for the old code is considered a good thing about PHP. I love BASIC because I can boot up a C64 and the code I wrote 20 years ago still works today!

Re: I Like PHP

#157

Earlier quoted context omitted.

Here is some PHP code: $x = "0"; if(!$x){ echo "0 is false"; } If you understand why it's crazy that PHP prints "0 is false" when you execute that, you're probably better off jumping ship now. If you don't, you'll probably appreciate the low barrier to entry for PHP more than any benefit you'd gain.

I understand why it prints zero is false, and personally I feel that it makes perfect sense. Indeed I approve of it. The fact that strings can be evaluated as numbers is great for accepting input from GET or POST because it means that there is no need to worry about explicitly casting strings to numbers. Of course, input type validation is still important, and if a variable input by the user is supposed to be numeric…

Perl does the same thing with type coercion, and "0" in Perl is false. However, the thing that Perl does that PHP doesn't is have different operators for strings and numbers.

Don't get me wrong, I think conflating strings and numbers is a bad idea, but if you're going to conflate strings and numbers, then having separate operators is the right thing to do.

Re: I Like PHP

#158
post #9

Earlier quoted context omitted.

I think it's probably easier to create unmanageable spaghetti with PHP. It's not that you can't build a large project in PHP, it's that it's easier to foul up. By far the part of PHP that shines for small projects and causes havoc in large is the way includes work. It's possible to be disciplined about this, but it's not common. I remember many times searching in vain for some function or another that was included so…

One of our struggles at Facebook was actually with circular includes that made our php codebase super tasty spaghetti. File A includes File B includes File C includes File A by about 10000 files. It was for a very scary trying to change a core library during this time because it was almost impossible to figure out where all it was included and impossible to test all the code that touched it. Additionally, we were bas…

That sounds like it could be useful to the PHP community. Are there plans to open source it?

Re: I Like PHP

#159
post #86

Earlier quoted context omitted.

Any particular reason you're linking to Symfony instead of Symfony2? I find the latter so much easier to read and work with it's not even funny.

I'm not sure about that claim. I've been working with SF for years and tried SF2 during early beta and I don't think it's that clear cut. Then again, I don't care that much so - carry on

The SF2 docs have really come along since the early beta. As a beginner looking at both for the first time SF2 seems more clear.

Re: I Like PHP

#160
post #18

Earlier quoted context omitted.

You can't blame PHP because the developers using it write messy code. I'll have the same problem in Java. I'll need to find out where I implemented some logic, and have to start digging through classes and following my own breadcrumbs until I find it sometimes. Just because I commented my code poorly, or put logic in the wrong place isn't the fault of Java, it's my own, and the languages, Java and PHP, in my opinion,…

It happens with any language. But at least in Java you're limited (as far as I know) to looking through what you've explicitly imported. If you include a file in PHP, you have access to everything that that file included in itself, and everything that those files included, and so forth.

Excuse my ignorance, but don't you have the same behavior with `require` in Ruby? How are the behaviors of Ruby's `require` and PHP's `include_once` different?
Post reply on HN