Using E_ALL|E_STRICT a good practice?
Filed Under (Uncategorized) by Wenbert on 28-09-2007
Tagged Under : PHP
I have been using Zend Framework for a few months now, and I really find the E_ALL|E_STRICT set in the bootstrap file really neat. See sample code below:
error_reporting(E_ALL|E_STRICT);echo $var; //display an unset variable. A notice will appear. //using an unset variable inside an if()-condition will also display the notice message //i use this kind of checking all the time, but i think it would be better to use //isset() since E_ALL|E_STRICT makes your code "cleaner" if ($var) { echo $var; } //we can avoid this if we use isset() if(isset($var)) { echo $var; } //so before using a variable, i would set it to '' on the top part of my code $var = ''; echo $var; //no notice message will be displayed.
So, I can no longer use variable on the fly. I have to set it somewhere on top of my code and set it to something. Putting a comment beside it really helps too.
$str1 = ''; //Street Address $str2 = ''; //Building Number $str3 = ''; //Country ...the rest of my code...
Related posts:
- PHP: Ternary Operator This is one my favorites. Sometimes I use this when...
- 40 ways to optimize your PHP Code A must read for PHP Programmers. Here is the first...
- Simple CAPTCHA Tutorial with Zend Framework UPDATE 2008-10-24 This guy has an updated post for Zend_Captcha....
- Cron job examples for newbies Here are a few examples from this site. 01 *...
Related posts brought to you by Yet Another Related Posts Plugin.
