
PHP best practices - The dos and don'ts - dskhatri
http://talks.php.net/show/php-best-practices
======
aston
Awesome how I can't see the site in IE because the author doesn't like the
browser.

Great way to get people to read your blog. Not to mention the horrid UI even
when I fire up the fox...

~~~
ks
I agree. The UI is terrible. It was pure luck that I tried the arrow keys to
navigate. And just blocking IE users like that is pure arrogance.

------
troels
> Exceptions leak a little bit of memory when thrown

So their suggestion for dealing with a limitation of the language
implementation, is to not use a feature? Great.

Also, teaching people to do ridiculous sub-optimisations, like using ++$i
instead of $i++ isn't really what I think of as best practice. Or telling
people to avoid OO because it's slow. Now I know, where those poor newbies get
this stuff from ...

------
marcus
Apparently a working UI isn't considered best practice...

Probably much easier to write secure, fast, elegant code when it doesn't need
to do anything or interact with users...

------
Funky_
The dos and don'ts of UI design should be their first project. :)

~~~
ks
And there are several don'ts in the slides too. Never give variables the same
name as functions or other parts of the language.

They named their variables $int, $string and $bool...

~~~
randallsquared
In PHP it hardly matters, since variables have their own namespace. PHP is a
lisp2.

~~~
SwellJoe
It might matter to the human reading the code.

~~~
randallsquared
Well, sure, but that cuts both ways. :) It's convenient to have names like
$bool and $int for didactic purposes, at least.

------
scooter53080
The third example on the type safety slides bugs me (using the type safe
comparison operator to prevent both a boolean true and non-zero int evaluating
the same.) I would prefer use of a consistent return type from the function to
begin with. I guess since some built in php functions behave this way, it's
important to know/use...but I don't think I would recommend writing a function
such that the type safe equal check is necessary.

------
henryw
Interesting stuff from the slides:

    
    
      Use commas with 'echo' instead of dot concatenation
      Where possible use ++$i instead of $i++
      Use the class of ctype functions to check strings
    

Lots of slides here: <http://talks.php.net/>

------
dskhatri
Unfortunately, the slide navigation seems to be missing. Can only navigate
slides by including the slide number in the URL eg.
<http://talks.php.net/show/php-best-practices/19> for slide 19.

~~~
aaroneous
Right and left arrows on my keyboard worked for me :]

~~~
dskhatri
oops.. thanks! :)

