Ask HN: PHP Tricks and Best Practices?

https://news.ycombinator.com/item?id=347675
by jmtame • 18 years ago
28 37 18 years ago

Hi everyone,

I have scoured the YC forum for a post on great PHP tricks and best practices, but found nothing. Maybe I'm not looking hard enough, but I would appreciate it if anyone knows of great sites or tutorials. I use CodeIgniter (excellent classes, typical MVC setup) and jQuery (uses a lot of method chaining, huge fan of this). But I still find myself writing a lot of native PHP for my app.

For example, I wasn't aware of the list() function until someone was helping me write a method to convert times. I've noticed when working with another programmer on a project that he's using sprintf() instead, and it surprisingly makes the code a lot cleaner. I'm finding myself doing more algorithm-style methods, dealing a lot with arrays and a bunch of if's/conditionals (tertiary if's are great!).

Just using these as examples, I feel like there should be a cheatsheet of best practices and ways to minimize the amount of native code written somewhere but I'm not seeing it =]

*Edit: I'm going to open up CI's class files and look at how they wrote everything. Perhaps a good way of doing this is to look at other frameworks? Any suggestions there?

Related Stories

Loading related stories...

Source preview

news.ycombinator.com