Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Show all variables that have been set on a page.
Old 05-21-2008, 05:37 PM Show all variables that have been set on a page.
Inet411's Avatar
Skilled Talker

Posts: 88
Name: programmer
Location: internet
Trades: 0
Here's an odd question.
Is there any way (without knowing what variables have been set) to display the output of all the variable on your page.
ie.
$a=9;
$blah=10
$why_do_i_need_this_pointless_functions='yes';

ie. if there was a function like:
show_vars();
and it would output
9
10
yes

Remember 'without' knowing what variables are set, or even the variable names.

for example if it was all in a post I could easily:
foreach ($_POST as $key=>$value) {
echo $key." ".$value."<br />";
}

but if the variable have been set in the page and not in a post,get,session or cookie.

Strange request I know....
__________________

Please login or register to view this content. Registration is FREE

Inet411 is offline
Reply With Quote
View Public Profile Visit Inet411's homepage!
 
 
Register now for full access!
Old 05-21-2008, 08:19 PM Re: Show all variables that have been set on a page.
Arenlor's Avatar
Ultra Talker

Posts: 462
Name: Jerod Lycett
Location: /home/arenlor
Trades: 0
I did some research and found a few things, edited a few of them together to get this, which you should be able to edit as needed:
PHP Code:
<?php function vars($vars$exclude){
    
$temp1 array_values(array_diff(array_keys($vars), $exclude));
    
$temp2 = array();
    while (list(
$key$value) = each($temp1)) {
        global $
$value;
        
$temp2[$value] = $$value;
    }
    return 
$temp2;
}
$exclude = array('GLOBALS''_FILES''_COOKIE''_POST''_GET''_SERVER''_ENV''HTTP_ENV_VARS''HTTP_POST_VARS''HTTP_GET_VARS''HTTP_COOKIE_VARS''HTTP_SERVER_VARS''HTTP_POST_FILES''_REQUEST''exclude');
$vars get_defined_vars();
print 
"<pre>";
print_r(vars($vars$exclude));
print 
"</pre>";?>
__________________
PHP Code:
<?php echo "Hello World"?>
HTML Code:
<html><head><title>Hello World</title></head><body><p>Hello World</p></body></html>
Arenlor is offline
Reply With Quote
View Public Profile Visit Arenlor's homepage!
 
Reply     « Reply to Show all variables that have been set on a page.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09776 seconds with 12 queries