3 PHP Tips For Product Developers

By Angsuman Chakraborty, Gaea News Network
Wednesday, August 23, 2006

Three lessons I learned the hard way while developing a PHP based product, Translator Plugin Pro for WordPress. Let me know if you find them useful.

1. PHP is no Java.
I don’t intend to be sarcastic. In reality I sorely miss the comfort of Java in more ways than one.
PHP lacks several built-in checks of Java to ensure defect free coding; features like strong typing, checked exceptions (by default), and lack of variant types (variable which can take on any data types). So you have to be extra careful in PHP to write high quality code. Also PHP is not as platform independent as Java. What I mean is that PHP has several platform dependent capabilities or lack thereof which makes it harder to make it work across platforms.

2. You best friend for PHP development is:
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

This little piece of code thrown in at the top of your file is arguably the best PHP debugging tool you can find. All your errors, warnings and even notices are displayed on your browser for you to correct.

3. Use file based logging instead of logging on browser. Logging on browser messes up your page layout and can even cause additional problems thereby obscuring your true defect. The best and unobtrusive way to log is to a file. You can try my technique for simple php logging. Use logging for easy debugging of your code.

YOUR VIEW POINT
NAME : (REQUIRED)
MAIL : (REQUIRED)
will not be displayed
WEBSITE : (OPTIONAL)
YOUR
COMMENT :