papaface Posted October 27, 2009 Share Posted October 27, 2009 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 More sharing options...
papaface Posted October 27, 2009 Author Share Posted October 27, 2009 Got it: echo "<pre>"; ob_start(); var_dump($GLOBALS); $a=ob_get_contents(); ob_end_clean(); echo "</pre>"; Thanks Link to comment https://forums.phpfreaks.com/topic/179240-solved-globals-as-formatted-string/#findComment-945683 Share on other sites More sharing options...
salathe Posted October 27, 2009 Share Posted October 27, 2009 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 https://forums.phpfreaks.com/topic/179240-solved-globals-as-formatted-string/#findComment-945689 Share on other sites More sharing options...
papaface Posted October 27, 2009 Author Share Posted October 27, 2009 Thanks Link to comment https://forums.phpfreaks.com/topic/179240-solved-globals-as-formatted-string/#findComment-945691 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.