Smashing Magazine PHP tips

Posted in CakePHP on 20.11.2008.

Smashing Magazine has smashed a list of "advanced tips" for PHP. Let's see..

First of all, I'm writing this, because the list contains CakePHP. The list is here:

10 Advanced PHP Tips To Improve Your Programming

Take a look at item 8! Let's hope this will spread the word about CakePHP even more.

Now, about the rest of the tips.

1. Use an SQL Injection Cheat Sheet

Fair enough, it's good to know. But Cake does this for me, so no worries :-)

2. Know the Difference Between Comparison Operators

Um...okay. Isn't this included in every tutorial for beginners?

3. Shortcut the else

This might be handy is some rare situations, but I don't think the speed gain is really worth it. And it certainly doesn't make the code much clearer.

4. Drop those Brackets

Item 4 is complete rubbish. "saves space and time in your code"? What space and time? I'm going to save space by not adding brackets? I guess some people still have 1MB disk drives..

5. Favour str_replace() over ereg_replace() and preg_replace()

Well, obviously str_replace() is faster than ereg_replace() / preg_replace(), but sometimes, str_replace() can't get the job done. Ergo, this one should be called: "5. Don't write dim-witted code"

6. Use Ternary Operators

This item is very questionable. Ternary operator makes your code a bit more unreadable and is rarely applicable as such.

7. Memcached

No comment there.

8. Use a Framework

CakePHP is listed first, with a site screenshot, so obviously this item is fine.

9. Use the Suppression Operator Correctly

Obviously a good advice: never use the suppression operator unless absolutely necessary.

10 Use isset instead of strlen

Item 10 is entirely misleading, so read the linked article to see what they mean. I'd still choose not to use isset() for this.

Overall, I don't see how this could be a list of "advanced tips", as even my toilet seat knows the difference between operators. But, I'll let you decide..

Article comments — View · Add

Page 1 of 1

villas :: 09.12.2008 08:49:51
>> even my toilet seat knows the difference...
Lavatorial wit - I love it! Thanks for the entertaining article and all your great work on Neutrino, I'm really looking forward to the next update.
lecterror :: 10.12.2008 03:00:19
You're welcome! Spending a lot of time in the loo does help with the humour.. :)

I haven't worked on Neutrino for a few weeks now, it appears I have to move to a new apartment soon. But I have some ass kicking features planned for the next release, it just might take longer than I thought..