More About PHP Web Development in IndiaPosted by Stan Pritchard, on Dec, 2013
Of all the web development languages, PHP is the most popular, with over 20 million domains using it. Megasites like Facebook and Wikipedia use it, as do smaller, open-source projects like Drupal and WordPress. Here, we’ll share some things we wished we knew about Php Web Development in India.
PHP Classes and Core Functions
If you’re trying to do something that’s already been done, there’s probably a PHP class or function you can use. Before creating a function, check your PHP manual first–chances are, it’s already been done.
Create Configuration Files
Instead of scattering your database settings to the four winds, why not put together one file that contains all your connection settings and build it into all PHP scripts you make? If things need to be changed later on, it can be done in one place. Putting everything together is useful when you need to use a set of functions and constants through more than one script.
Clean the Data Before it Becomes Part of Your Database
SQL injections are common, and unless you want to deal with the hassle later on, you should sanitize what goes into your database. Before you do anything else, learn how your apps can become compromised, and learn more about SQL injections.
Don’t Turn off the Error Reporting in the Development Stage
The only thing you’ll learn by looking at PHP’s “white screen of death” is that something has gone wrong. When building an app, leave display errors and reporting on, so you’ll see runtime errors and pinpoint the problem faster. You can set these configurations in the php.ini file of your server, or you can add them to the top of your PHP scripts with the ini set function.
Don’t Over-Comment Scripts
It’s good to document your code through script comments, but you don’t have to comment every line. Leave comments on the tricky parts of source code so you’ll know what’s going on when you come back to it, but you don’t have to comment simple code such as that for MySQL connections. In most cases, good code explains itself.