PHP
Diary of a late, late adopter
Tuesday, October 28, 2003

A warning to ye...

I can't impress upon ye enough:  set error_handling to E_ALL (verbose) when developing PHP.  You will cut your errors in half.  You can do this in three ways: 

  1. uncomment the following line in your php.ini file: error_reporting = E_ALL .  This will affect all PHP scripts
  2. add the line error_reporting = 2047 in an .htaccess file.  This will affect only php files in or below the directory of the .htaccess file.
  3. add a line of code at the start of every php page: error_reporting (E_ALL);  This will affect only the files that you alter.

After you do this you may get a whole page of warnings about undeclared variables.  This is a good thing, since it forces you to declare all variables and lets you know when you introduce new ones into the mix by mistake.  You will  at some point mis-type variable names.  Without error reporting turned verbose, PHP accepts these mistakes as real variables:

$species_code = "WAE";

if($speces_code == "WAE"){ //do stuff}

The above code exhibits a bad feature of PHP; that you don't need to declare variables before using them. I introduced a variable called speces_code to the PHP script and since it is blank it is not equal to "WAE". It just skipped over this comparison without a blink!

Also, set error reporting to zero when in production so that visitors cannot peer into the inner workings of your code and directory structure when they encounter an error.


11:47:51 AM    comment []





© 2003 mcgyver5
Last Update: 11/4/2003; 8:33:29 AM

Click here to visit the Radio UserLand website.

 











October 2003
Sun Mon Tue Wed Thu Fri Sat
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
Sep   Nov

Subscribe to "PHP" in Radio UserLand.
Click to see the XML version of this web page.
Click here to send an email to the editor of this weblog.