1. Use PHP Core Functions and Classes
Always give preference to the functions already defined and use php's core classes to acheive your goal before defining your own function or classes. For example There’s no need to create a function to remove the white space at the beginning and at the end of a string when you can just use thetrim()
function2. Using Configuration File
Always create a configuration file for variables which are used globally in your application. For example Instead of having your database connection settings scattered everywhere, why not just create one master file that contains its settings, and then include it in your PHP scripts? In case of changes, you will need to change only one file instead of changing multiple files.3. Always Sanitize Data
Sanitize user input before you start any processing on the data to avoid sql injection or cross-site scripting xss attack. Luckily, there’s a PHP functions that can help.htmlspecialchars
mysql_real_escape_string are few functions to santize your data. you can write your own function to avoid
cross-site scriptingattack4. Comment Your Code
Don't forget to comment your code. A well comment code not only helps other to understand the code fast but also helps you to generate a good technical documentation on fly. there are tools which does that.phpDocumentor is a good tool which helps to generate technical documentation out of your code, if commented properly.
10. Connect with Other PHP Developers
You don’t know all. E ven if you think so, there are thousands of other professionals out there who know how to do something better than you do. Join a PHP community like PHPDeveloper and interact with others to sharpen your skills.Wish you to become a better PHP developer. You can also help me referring good things. Your inputs and suggestions are welcome.
No comments:
Post a Comment