Chris Bier Chris Bier - 5 months ago 39
PHP Question

Writing Clean and Efficient PHP Code

I have been looking around online and I cant seem to find an article on this that isn't totally outdated. Does anyone have any good articles that give some good advice? What I have read so far is good, and a bit helpful, but I want to have modern code examples, not ones from 2002.

I have coded an extensive PHP/MySQL program and I am trying to make it better now, any suggestions?

People are suggesting frameworks, and I appreciate it but I am looking for coding tips for raw PHP Coding. The whole application is already done and it would be very lengthy to recode the entire thing in a framework.
I will be checking those out for future projects though. Does anyone know or have any tips for Writing Clean and Efficient PHP Code?


Use Smarty

Write to patterns as much as possible.

Edit for the Question Edit

Clean and efficient PHP isn't much different than any other language. Practice good Object oriented principles. Focus on Encapsulation, Separation, and Polymorphism. Refactor often, and Utilize design patterns as much as possible.

There are many sites that focus on these principles. Some use Java, C++, etc. to demonstrate the principles, but it shouldn't be too difficult to convert them over to php.