View previous topic :: View next topic |
Author |
Message |
Toasty -
Joined: 21 Feb 2008 Posts: 298 Location: Chicago, IL
|
Posted: Sun Mar 23, 2008 9:00 pm Post subject: Dumping all variables into one |
|
|
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 |
|
|
roganty -
Joined: 08 Jun 2004 Posts: 357 Location: Bristol, UK
|
Posted: Sun Mar 23, 2008 9:38 pm Post subject: Re: Dumping all variables into one |
|
|
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 |
|
|
rrinc -
Joined: 24 Feb 2006 Posts: 725 Location: Arkansas, USA
|
Posted: Sun Mar 23, 2008 9:44 pm Post subject: |
|
|
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 |
|
|
roganty -
Joined: 08 Jun 2004 Posts: 357 Location: Bristol, UK
|
Posted: Mon Mar 24, 2008 3:28 pm Post subject: |
|
|
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 |
|
|
|