News for hackers. Stuff that matters.
Re:PHP Tips and Tricks - Codular by encoderer on Sunday July 29, 2012 @04:46PM (#4309677)
I've used PHP a lot, work at a name-brand startup that uses a fair bit of PHP in the stack, and have an OSS PHP project I'm proud of (https://github.com/shaneharter/PHP-Daemon). That is to say, I'm not a PHP hater. I see many flaws in the language, many many actually, but I'm not a hater.

But I really disagree with some of this.

First, why call variable references "pointers"? You're just breeding ignorance there. Understanding pointers is a valuable skill for a software engineer, even if they'll never use the skill directly in their day job as a PHP developer.

Second, you're introducing concepts that are a little sleazy like variable variables without any commentary on downsides or best practices. There is effectively nothing you can do with a variable variable that you cannot do with an associative array.

And fine, if you don't want to editorialize, if you want to just teach facts of the language without adding opinion, why invent the term "pointers" that, as far as I've ever read, is not used in any official PHP documentation.

Re:PHP Tips and Tricks - Codular by michaelmior on Sunday July 29, 2012 @05:50PM (#4309868)
Agreed on some points. A mention of the serious trouble you can get in with variable variables is in order. I would never feel comfortable using user input to dictate a variable reference.
Re:PHP Tips and Tricks - Codular by FuzzyDunlop on Sunday July 29, 2012 @06:11PM (#4309916)
I think it would have been worth pointing out the slightly more readable syntax for variable variables (and other metaprogramming features within PHP):

    ${$var};
    ${$name.'Controller'}->function();
    $something->{$functionName}();
With all the appropriate warnings, of course. For a start, don't find excuses to implement this style of code. You almost certainly don't need it for a basic website.
Re:PHP Tips and Tricks - Codular by grakic on Sunday July 29, 2012 @05:33PM (#4309816)
For TimeClass one should not assume 86400 seconds in a day, and use DateTime::diff() instead. PHP The Right Way is better on this: http://www.phptherightway.com/#date_and_time

With the autoloader, there is no need to do include_once(), simple include() is enough. The file will be loaded only once for every class.

Re:PHP Tips and Tricks - Codular by juan_juarez on Sunday July 29, 2012 @11:38PM (#4310783)
Nearly any time you think "I need to have variable variable names", you should probably be using an array (dictionary, hash, whatever your language gives you). They're no more difficult to use & far harder to make horrible mistakes with.