Live data from Hacker News

PHP: The Right Way

phptherightway.com

61–70 of 233 posts

Re: PHP: The Right Way

#61
post #57
post #52

Earlier quoted context omitted.

No it isn't, there's GPG signing and things going on there.

No it isn't, there's GPG signing and things going on there. That's really just Cargo Cult security, isn't it? Signed packages can just as easily be malicious. In fact a repository server could be a much worthier target for the injection of bad code than a single, relatively obscure web project.

The difference is the same as between http and https.

Re: PHP: The Right Way

#62
post #44

While PSR-1 has pretty good universal guidelines, PSR-2 goes too far in insisting on subjective preferences (spaces over tabs, 80-char lines, bracketing styles). We should not pretend that there is a "correct" answer to these choices, just as long as they stay consistent on a per-project basis. All told, I love site, and I hope it keeps iterating. PHP may be ugly, but it's powerful, and most of its bad reputation com…

+1 , I still don't know where this 'spaces over tabs' crap comes from. My guess is that it is good for things that must be done from a console (as opposed to using an IDE). But it has no place in PHP. Tabs + spaces break on different configurations? It's not because of tabs, it's because of spaces! Tabs are flexible, spaces are not. What's next, will I be forced to use a particular font size too?

Re: PHP: The Right Way

#63
post #57

Earlier quoted context omitted.

No it isn't, there's GPG signing and things going on there. That's really just Cargo Cult security, isn't it? Signed packages can just as easily be malicious. In fact a repository server could be a much worthier target for the injection of bad code than a single, relatively obscure web project.

The difference is the same as between http and https.

Exactly. SSL doesn't guarantee that the content is benign either. But there is also a key difference when it comes to software distribution. On a typical web connection you worry about 3rd parties observing your content and maybe even spoofing it later (e.g. stealing your cookies), but as far as downloads are concerned your main worry is actually content integrity. This integrity is threatened by both malicious publishers and outside attackers injecting malicious code into otherwise benign software - having a GPG signature alongside your rpm does (almost) nothing to mitigate that risk.

Re: PHP: The Right Way

#65

I didn't understand this: 4.2. Properties This guide intentionally avoids any recommendation regarding the use of $StudlyCaps, $camelCase, or $under_score property names. Whatever naming convention is used SHOULD be applied consistently within a reasonable scope. That scope may be vendor-level, package-level, class-level, or method-level. 4.3. Methods Method names MUST be declared in camelCase().

What don't you understand specifically? It can't be any clearer, and it's obvious the reasons for this with what the PSR is. So, I'm confused as to what you find confusing?

Re: PHP: The Right Way

#66

I didn't understand this: 4.2. Properties This guide intentionally avoids any recommendation regarding the use of $StudlyCaps, $camelCase, or $under_score property names. Whatever naming convention is used SHOULD be applied consistently within a reasonable scope. That scope may be vendor-level, package-level, class-level, or method-level. 4.3. Methods Method names MUST be declared in camelCase().

Methods should be camelCase(), but properties (fields?) can be any convention as long as its consistent throughout.

Re: PHP: The Right Way

#67
post #57

Earlier quoted context omitted.

No it isn't, there's GPG signing and things going on there. That's really just Cargo Cult security, isn't it? Signed packages can just as easily be malicious. In fact a repository server could be a much worthier target for the injection of bad code than a single, relatively obscure web project.

The difference is the same as between http and https.

Not sure if you are trying to make a joke (and if so, it's incredibly subtle), or you are being serious. In case you are serious, to explain how HTTPS as it's used means anything about the trust-worthiness of the two parties involved?

Re: PHP: The Right Way

#68

I didn't understand this: 4.2. Properties This guide intentionally avoids any recommendation regarding the use of $StudlyCaps, $camelCase, or $under_score property names. Whatever naming convention is used SHOULD be applied consistently within a reasonable scope. That scope may be vendor-level, package-level, class-level, or method-level. 4.3. Methods Method names MUST be declared in camelCase().

It looks clear to me. Properties refer to object properties or variables and Methods refer to object methods or functions. This standard recommends three formating conventions for variable names and requires that all functions be written in camelCase.

Re: PHP: The Right Way

#69
post #51
post #24

Earlier quoted context omitted.

SQL injection attacks alone are almost always a result of not filtering input...

This the wrong way to look at it, and yes, the PHP world always does this wrong because they're too focused on HTML. SQL injection occurs when you're not escaping data while producing output , namely, an SQL query sent to the DB. XSS attacks occur when you're not escaping data while producing HTML, but you don't need angle brackets to do it. allows for XSS injection with just a quote character. Header injection attac…

> the PHP world always does this wrong because they're too focused on HTML.

No. The PHP world recommends, time and time again, using PDO and binding variables to queries. I've yet to meet an individual who does it the other way, other than people who are relying on extremely outdated tutorials (7+ years ago). Hell, even this document does. This document, unfortunately, uses the word filter in the wrong way, but the intention is still fine.

Re: PHP: The Right Way

#70
post #6

Something to consider mentioning - there are some in PHP these days that take this sort of stuff a bit too far. Drives me nuts to see people writing classes to encapsulate a 3 column database result. So much overhead and boilerplate.

You should check out Java sometime.

That's exactly my problem with it. It's just that when you do in PHP, you don't get any of the benefits you derive from all the Java BDSM.
Post reply on HN