Miscellaneous
  Home arrow Miscellaneous arrow Page 4 - PHP Debugging Tutorial
Codewalker Forums 
  Tutorials  
Database Articles  
Miscellaneous  
Navigation Usability  
PEAR Articles  
Programming Basics  
Server Administration  
XML Tutorials  
  Reviews  
Database Book Reviews  
Linux Book Reviews  
Miscellaneous Reviews  
PHP Book Reviews  
PHP Software Reviews  
Server Admin Reviews  
SQL Tool Reviews  
  Code Gallery  
Content Management Code  
Contest Code  
Counters Code  
Database Code  
Date Time Code  
Discussion Board Code  
Email Code  
File Manipulation Code  
GUI Code  
Link Farm Code  
Miscellaneous Code  
Search Code  
Site Navigation Code  
User Management Code  
Forums Sitemap 
Download TestComplete 
JMSL Numerical Library 
IBM® developerWorks
Weekly Newsletter 
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MISCELLANEOUS

PHP Debugging Tutorial
By: Codewalkers
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2002-07-26

    Table of Contents:
  • PHP Debugging Tutorial
  • Coding Style Primer
  • Common Errors
  • Your Arsenal
  • In closing

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    PHP Debugging Tutorial - Your Arsenal


    (Page 4 of 5 )

    Not getting errors on the page, but it's simply not doing what you expect it to? print_r(), print(), exit() and IE's View Source (alt-v-c) are your friends. use them well and they'll uncover a wealth of information.

    Example Situation : You're posting information from a form, but nothing seems to happen on resulting page.

    Diagnosis : Use print($yourvariable) in the function you're trying to use it. If empty, ask yourself why. If you're still baffled, simply do print_r($GLOBALS); exit(); view source, and see if you can find your posted variable in the resulting mess. You should be able to pick out what you're doing wrong from a print_r($GLOBALS) 95% of the time, whether it be posting files, variables, arrays, radio boxes, checkboxes, query strings, etc. quite quickly.

    Remember print("<pre>"); print_r($array); print("</pre>"); exit(); can be very useful when working with rather complex arrays or regular expressions (that returns the results in an array)

    Make sure you test all of your functions thoroughly before actually using them (except when you start being able to think in code and have no need to test anything coz you simply know it's going to work, like I do at work ;P). Call the function, print results, check the database to make sure that it did what it was supposed to, etc. Try it from all different angles. Once you _know_ a function is working, it takes quite a bit of modding for it to just break.

    More Miscellaneous Articles
    More By Codewalkers


       · put this at the top of your php... It will make your code show all errors (even if...
       · Make sure you remove error_reporting(E_ALL) or turn it off by changing it to...
     

    MISCELLANEOUS ARTICLES

    - Stopping CSRF Attacks in Your PHP Applicatio...
    - Quick and Dirty AJAX Tutorial
    - Flickr Puzzle Mashup
    - The PAVISE of Security
    - Creating a CAPTCHA with PHP
    - Sending SMS Thru HTTP
    - The Postal Fix - Part 2
    - Adding Mail with Exim
    - The Postal Fix - Part 1
    - Create Your Own Custom API
    - Adding Drop Shadows with PHP
    - Writing a Basic Authentication System in PHP
    - Overlapping Images with GD
    - Using Sockets in PHP
    - Dynamic CSS with PHP





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT