Miscellaneous

  Home arrow Miscellaneous arrow Page 4 - PHP Debugging Tutorial
MISCELLANEOUS

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

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

  •  
     

    SEARCH CODEWALKERS

    TOOLS YOU CAN USE

    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

    blog comments powered by Disqus

    MISCELLANEOUS ARTICLES

    - Oracle Database XE: Indexes and Sequences
    - Modifying Tables in Oracle Database XE
    - Oracle Database XE: Tables and Constraints
    - More on Oracle Databases and Datatypes
    - Oracle Database XE Datatypes: Datetime and L...
    - Oracle Database XE Datatypes: Character and ...
    - From Databases to Datatypes
    - Firefox 3.6.6 Released with Improved Plug-in...
    - Attention Bloggers: WordPress 3.0 Now Releas...
    - Reflection in PHP 5
    - Inheritance and Other Advanced OOP Features
    - Advanced OOP Features
    - Linux from Scratch V.6.6 Review
    - Linux Gaining in Strength
    - Install Slackware on Your Old PC


    © 2003-2012 by Developer Shed. All rights reserved. DS Cluster 2 - Follow our Sitemap