WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Global Dump Highlighted
Categories : PHP, Variables, Global Variables Click here to Update Your Picture
Stuart Cochrane
Date : May 21st 2003
Grade : 2 of 5 (graded 6 times)
Viewed : 5480
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Stuart Cochrane
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

This example comes in handy when you need to get a full list of all current state global variables anywhere in your script. The lists will be printed with code highlighting for easy viewing:). Useful for debugging in your browser.

The function simply dumps out a list of $_POST, &_GET, $_SESSION, $_REQUEST, $_COOKIE, $_ENV and $_FILE if available.

Just call <? echo dump_vars(); die; ?> anywhere in your code that you want the current variable state dumped.

There are many better solutions to help with debugging, but this is a quick way to get an applications current state.
This could be adapted to support 3d arrays also!!

<?php
function f_arr($arr) {
   
$fr = "<font color=red size=1>";
   
$fg = "<font color=green size=1>";
   
$fb = "<font color=blue size=1>";
   
$fk = "<font color=black size=1>";
   
$fe = "</font>";
   
$l = "$fg [ $fe";
   
$r = "$fg ] $fe";
   
$a = "$fk => $fe";
   
    if(
is_array($arr)) {
           foreach(
$arr as $k=>$v){
           
$out[] = $l.$fb.$k.$fe.$r.$a.$fr.$v.$fe;
        }
    }
    if(
is_array($out)) {
        return
implode("<br />", $out);
    } else {
        return
false;
    }
}

function
dump_vars() {
   
$out = "";
    if(
$a = f_arr($_SESSION)) {
       
$out .= "SESSION[] ( <br><blockquote> $a </blockquote>) <br>";
    }
    if(
$a = f_arr($_REQUEST)) {
       
$out .= "REQUEST[] ( <br><blockquote> $a </blockquote>) <br>";
    }
    if(
$a = f_arr($_POST)) {
       
$out .= "POST[] ( <br><blockquote> $a </blockquote>)
<br>"
;
    }
    if(
$a = f_arr($_GET)) {
       
$out .= "GET[] (<br><blockquote> $a </blockquote>)<br>";
    }
    if(
$a = f_arr($_COOKIE)) {
       
$out .= "COOKIE[] (<br><blockquote> $a </blockquote>)
<br>"
;
    }
    if(
$a = f_arr($_ENV)) {
       
$out .= "ENV[] (<br><blockquote> $a </blockquote>)<br>";
    }
    if(
$a = f_arr($_FILES)) {
       
$out .= "FILES[] (<br><blockquote> $a </blockquote>)
<br>"
;
    }
    return
$out;
}
?>


Example Usage:
<?php
echo dump_vars();
die;
?>



getting the name of the current script and query string
Categories : PHP, Global Variables, Variables, URLs
How to make sure a that $foo is from a cookie and not from the URI.
Categories : PHP, Variables, Global Variables, Cookies
Include a file inside of a function and have the included variables be global.
Categories : PHP, Variables, Global Variables
Simple script to passing persistent and growing array between recalls of one page (manipulate little stack).
Categories : Arrays, Global Variables, PHP, HTML and PHP, Variables
Make old style (PHP3) scripts using GET, POST, COOKIE and File uploads (POST) compatible with PHP 4.2.0
Categories : PHP, HTML and PHP, Global Variables, Cookies, Variables
Initialize global variables for every field in a table. This version requires that phplib is installed on your server.
Categories : Global Variables, MySQL, PHP, Variables
How to pass an array to a function, or how to define a function wich recieves an array.
Categories : Variables, PHP, Arrays
using global variables
Categories : Global Variables, PHP
How can I know about what Operating System is running on server from PHP?
Categories : PHP, Global Variables
Current Page's URL using PHP
Categories : PHP, Beginner Guides, Global Variables
Newbie Notes #5 - To double quote, or single quote, that is the question
Categories : PHP, Beginner Guides, Variables
Accessing GET and PUT variables with HTTP_GET_VARS on Win2K.
Categories : PHP, Windows 2000, Variables
Functions to read a template file and fill in PHP variables. It will also fill in array variables, displaying parts of the template multiple times.
Categories : PHP, Variables, Filesystem
Automatic global variable definer
Categories : PHP, Variables, Beginner Guides
How to know which input button of type image was pressed in a form with multiple image buttons (_x and _y) in PHP?
Categories : PHP, Variables, HTML