Jump to content

[SOLVED] $GLOBALS as formatted string


papaface

Recommended Posts

I am trying to email a list of $GLOBALS values to an error email address so that one of my complex scripts can be debugged properly.

When I try the following:

mail('*****','*****','here is a list of all the vars in this session:
			<pre>'.$GLOBALS.'</pre>

I simply get an email which has <pre>1</pre> obviously due to the fact it is an array. print_r($GLOBALS) does not work either.

So my question is, how can I send a list of the array values in the format produced by print_r  i.e

            [HTTP_KEEP_ALIVE] => 300
            [HTTP_USER_AGENT] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3
            [PATH] => /bin:/usr/bin
            [QUERY_STRING] => 
            [REDIRECT_STATUS] => 200
            [REMOTE_ADDR] => 86.162.181.79
            [REMOTE_PORT] => 2965

Any help would be appreciated :)

Link to comment
https://forums.phpfreaks.com/topic/179240-solved-globals-as-formatted-string/
Share on other sites

print_r has a second argument called $return which is a boolean (default false) dictating whether the formatted value is returned as a string (true) or output directly (false).

 

$foo = array('a', 'b', 'c');
$debug = print_r($foo, TRUE);

echo $debug;

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.