Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Debugging multipage (session based) PHP applications

PHP's print_r function allows you to dump out the contents of a variable - and that includes more complex variables like arrays containing other arrays, objects, etc ... in a human (programmer!) readable form. By default, the output string is directly sent to the browser, but with a second parameter that's a true value, it is returned to you for further processing.

Here's an example of print_r's output being decorated to allow for special characters and to retain the spacing so that it can be displayed via the browser:

<?php print ("<pre>".htmlspecialchars(print_r($_SESSION,1))."</pre>"); ?>

And here is a sample of that running in our session demonstration:

PHP - How to debug a session based application
(run the demonstration here with that extra trace line now added; you'll find that our wrapper is maintaining your session history too, but that's another story!)

This is a particularly useful facility to use if you're debugging a multipage application and want to see how the data is passed from one page to another.

Remember - if you alter the PHP script that's running a multipage application, you'll probably need to delete the session cookie too ... otherwise you will have changed the program but your testing would continue with the old data!
(written 2009-07-09 07:56:17)

 
Associated topics are indexed under
H310 - PHP - Putting it all together
  [2635] A PHP example that lets your users edit content without HTML knowledge - (2010-02-14)
  [1962] Index Card System for Game Characters in PHP - (2008-12-27)
  [1840] Validating Credit Card Numbers - (2008-10-14)
  [1794] Refactoring - a PHP demo becomes a production page - (2008-09-12)
  [1754] Upgrade from PHP 4 to PHP 5 - the TRY issue - (2008-08-15)
  [1716] Larger applications in PHP - (2008-07-22)
  [687] Presentation, Business and Persistence layers in Perl and PHP - (2006-04-17)
  [468] Stand alone PHP programs - (2005-10-18)


Back to
PHP preg functions - examples and comparision
Previous and next
or
Horse's mouth home
Forward to
Who is Marc Schneider of Multilingual Search Engine Optimization Inc
Some other Articles
Understanding the new local government structure in Wiltshire
First courses for 2010
Python classes / courses - what version do we train on?
Who is Marc Schneider of Multilingual Search Engine Optimization Inc
Debugging multipage (session based) PHP applications
PHP preg functions - examples and comparision
Three recent questions on Tomcat Convertors
Monitoring and loading tools for testing Apache Tomcat
Dogs Trust, Dog Show, Newbury
Wiltshire - a chance to improve life for everybody
2672 posts, page by page
Link to page ... 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, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2010: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 344596 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho