Dumping all variables into one

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
Toasty
-


Joined: 21 Feb 2008
Posts: 298
Location: Chicago, IL

PostPosted: Sun Mar 23, 2008 9:00 pm    Post subject: Dumping all variables into one Reply with quote

I was looking to add something to my scripts that take all applicable variables in a script, and dump it into one variable so I can save it in a log.


For example, say I have the following variables:

$To = "user@resu.com";
$From = "kitten@nettik.com";
$IP = $_SERVER['REMOTE_ADDR'];


Different scripts use different variables, and I wanted to make one standard include that will grab all current variables at any point and output them (for example, a text file, or the screen) without having to add every variable name to the script.

Any ideas?
_________________
Audit the secure configuration of your server headers!
Back to top View user's profile Send private message Visit poster's website
roganty
-


Joined: 08 Jun 2004
Posts: 357
Location: Bristol, UK

PostPosted: Sun Mar 23, 2008 9:38 pm    Post subject: Re: Dumping all variables into one Reply with quote

Toasty wrote:
I was looking to add something to my scripts that take all applicable variables in a script, and dump it into one variable so I can save it in a log.


For example, say I have the following variables:

$To = "user@resu.com";
$From = "kitten@nettik.com";
$IP = $_SERVER['REMOTE_ADDR'];


Different scripts use different variables, and I wanted to make one standard include that will grab all current variables at any point and output them (for example, a text file, or the screen) without having to add every variable name to the script.

Any ideas?


A quick google and I found the answer!

and then I suppose you could run it through serialize()
_________________
Anthony R

Roganty
| Links-Links.co.uk
Back to top View user's profile Send private message Visit poster's website
rrinc
-


Joined: 24 Feb 2006
Posts: 725
Location: Arkansas, USA

PostPosted: Sun Mar 23, 2008 9:44 pm    Post subject: Reply with quote

This is probably way more than you want, but I'm sure you filter it out some way. When I tested it all of the script-defined variables tended to be at the end.

Code:
echo '<pre>';
print_r(get_defined_vars());
echo '</pre>';
?>


Edit: you beat me to it
_________________
-Blake | New Server :D
SaveTheInternet
Soy hispanohablante. Puedes contactarme por mensajes privados.
Back to top View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger
roganty
-


Joined: 08 Jun 2004
Posts: 357
Location: Bristol, UK

PostPosted: Mon Mar 24, 2008 3:28 pm    Post subject: Reply with quote

rrinc wrote:
This is probably way more than you want, but I'm sure you filter it out some way. When I tested it all of the script-defined variables tended to be at the end.

Code:
echo '<pre>';
print_r(get_defined_vars());
echo '</pre>';
?>


Edit: you beat me to it


Or you could use
Code:
print "<pre>";
print_r($GLOBALS);
print "</pre>";

_________________
Anthony R

Roganty
| Links-Links.co.uk
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group