Live data from Hacker News

PHP Commandments

biasedphp.com

11–20 of 117 posts

Re: PHP Commandments

#11
post #4
post #3

Earlier quoted context omitted.

Couldn't agree more with E_ALL|E_STRICT. The current legacy system I am maintaining took me 2 weeks to clear up 90% of the NOTICE errors for using undefined variables etc. Dirty code is dirty, and it is because of this that PHP has received so much negative publicity.

The completely brain dead naming conventions for function names (or rather, the lack thereof) is another. PHP has grown organically, just like the web, to fill a very irregular shaped niche and it shows that history in all the gory little details. That said it made me more money than any other programming language combined (including C, but it's a very close second). Probably a lot of people have similar feelings tow…

I haven't seen anywhere near the same level of hate for Ruby - and I can't help thinking it's because PHP is objectively worse. A lot of the problems listed in the article wouldn't arise in a language with a better module system (such as Ruby), for example.

Re: PHP Commandments

#14

8. NEVER create a file of useful functions, even if it's called helpers.php This smacks of such a broken thinking process, it makes my teeth itch. If you have commonly-used functions, they should be integrated with the commonly-used parts of your code. Example function used for debugging: function preint_r($arr) { echo ' '; print_r($arr); echo ' '; } Where would something like this fit, if not a general helpers.php t…

>Where would something like this fit, if not a general helpers.php type file?

In debugging.php alongside with other debugging helpers?

Re: PHP Commandments

#16
Can someone help me understand why a "helpers" or "utilities" file of functions is so bad?

Asking humbly because I do that and don't yet understand why it's bad / the alternative.

Re: PHP Commandments

#17

8. NEVER create a file of useful functions, even if it's called helpers.php This smacks of such a broken thinking process, it makes my teeth itch. If you have commonly-used functions, they should be integrated with the commonly-used parts of your code. Example function used for debugging: function preint_r($arr) { echo ' '; print_r($arr); echo ' '; } Where would something like this fit, if not a general helpers.php t…

You should install xdebug, and then var_dump will do what you want and a lot more.

Re: PHP Commandments

#18
These are the "PHP Commandments"? How about we set the bar a little higher? Anyone who has had longer than 1 day's worth of training with PHP should know these things.

Re: PHP Commandments

#19
Wow, this guy really hates CakePHP. If you know what you're doing and don't just presume Cake has done it for you, none of those problems should exist.
Post reply on HN