Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5
This is the forum to discuss the Wrox book Beginning PHP4 by Wankyu Choi, Allan Kent, Chris Lea, Ganesh Prasad, Chris Ullman; ISBN: 9780764543647
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 11th, 2004, 12:29 PM
Authorized User
 
Join Date: Jan 2004
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Debug Stuff

Hi,

I'm writing some debug code. I want to be able to output(print) all session variables and its value, all get variables and its value and all post variables and its value (all with out knowing the variables name, so I can't use $_GET or whatever). Can anybody help me or show me some good debug code.

Reply With Quote
  #2 (permalink)  
Old January 11th, 2004, 12:46 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Why wouldn't you be able to use "$_GET or whatever"? The following function var_dump, dumps out and provides information about, in this case, the arrays. You don't already have to know all possible indices in the arrays. It structures the information in a human-readable format, which is why the <pre> tags are neccessary.

http://www.php.net/var_dump
http://www.php.net/print_r is a simular function but does not provide as much information.

<?php
echo "Session variables:<br />";
    echo "<pre>";
        var_dump($_SESSION);
    echo "</pre>";
echo "Get variables:<br />";
    echo "<pre>";
        var_dump($_GET);
    echo "</pre>";
echo "Post variables:<br />";
    echo "<pre>";
        var_dump($_POST);
    echo "</pre>";

// ...etc
?>

hth,
Rich

:::::::::::::::::::::::::::::::::
Smiling Souls
http://www.smilingsouls.net
:::::::::::::::::::::::::::::::::
Reply With Quote
  #3 (permalink)  
Old January 12th, 2004, 04:33 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've posted this function before. It's incredibly useful:

function printr($var, $desc = '')
{
   echo "<pre>";
   if ($desc !== '') echo "{$desc}: ";
   print_r($var);
   echo "</pre>\n";
}


This lets you add an optional description to the variable you're printing out. Here are some examples:


$foo = "Some variable.";

printr($_POST, '$_POST before form processing');

if (isset($_POST['username']))
{
    $_POST['username'] = strtolower($_POST['username']);
}

printr($_POST, '$_POST after form processing');

printr($foo); // description parameter is optional.


Take care,

Nik
http://www.bigaction.org/
Reply With Quote
  #4 (permalink)  
Old January 13th, 2004, 10:18 PM
Authorized User
 
Join Date: Jan 2004
Location: , , .
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

nikolai and quesadilla5, thanks for replying! You guys are always answering questions and i appreciate that. thanks.

i was looking for something else design wise(a nice table layout) but your solutions produce the same results

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to: Have no borders and stuff! Apocolypse2005 Beginning VB 6 7 May 8th, 2007 11:56 AM
INI's and stuff! Apocolypse2005 Beginning VB 6 2 May 8th, 2007 11:38 AM
hp exam stuff ? olango Need help with your homework? 1 September 23rd, 2006 06:47 PM
Basic Stuff... Colm_L Javascript How-To 0 September 14th, 2006 08:02 AM
DAL 'stuff' pithhelmet VB Databases Basics 0 November 10th, 2004 04:42 PM



All times are GMT -4. The time now is 05:25 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.