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
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;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.