

Advanced PHP Tips Revisited - ninjac0der
http://www.smashingmagazine.com/2009/03/24/10-useful-php-tips-revisited/

======
jlujan
I wonder if the original intent of posting was to be helpful or for mockery.
My second language to learn was PHP, perl being the first, and I have since
moved on. I probably asked,( myself/google not others,) similar questions the
article covers. But the fact that articles like this continue to be titled
"Advanced..." is a hint to where the language and community are as a whole. I
think the bigger issue is a commingling of subjects. If your intent is to
learn PHP, learn programming with PHP as a language. If your intent is to
learn web development, learn web development in terms of available
technologies, industry standards, and best practices. A lot of the articles
content is laughable not because it is common sense PHP, but common sense
programming/web development. PHP != Web... or is that PHP !== Web?

------
trezor
Short summary:

1\. Validate/clean input. Preferably store data in 3 arrays to ensure
separation of input, cleaned data and cleaned data to be used with sql. Or
cleaned data to be used with prepared sql-statements. Uhm yes.

2\. The PHP type-system is retarded and can return integers treated as boolean
false. Compare against !== FALSE when 0 is a valid return value from whatever
function you just called, instead of simply checking the return value.

3a. The PHP runtime is retarded and wont choke if you refer to unexisting or
unitialized variables. Initialize variables.

3b. Shortcuts which saves you a few keystrokes can result in poor
maintainability. Use braces.

3c. Write readable (not "smart") code.

4a. Shortcuts which saves you a few keystrokes can result in poor
maintainability. Use braces.

4b. Be consistent.

5\. Use simple replace-functions when you don't need full regexp.

6\. The ternary-operator is advanced & confusing. We recommend against using
it.

7\. Caching might improve performance.

8\. Frameworks exists. You may or may not use them.

9\. Writing buggy code that causes errors is silly and costs resources. Try
not writing buggy code that needs to eat errors runtime.

10\. Strlen is slow. Use isset on strings as arrays to check for specific
lengths. Nevermind compromising rule 3c and in doing so also compromising rule
4b.

Call me picky, but I wont go as far as calling this advanced.

~~~
jackmoore
Ternary is advanced and confusing? It's neither of those things.

~~~
wlievens
It is when you use nested ternary operators and are too lazy to write
parentheses. I've seen code like

    
    
      a ? b ? c ? d : e : f ? g : h : i
    

Or something like that. That's not funny.

