<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Eddie On Everything &#187; print_r</title>
	<atom:link href="http://www.eddieoneverything.com/tag/print_r/feed" rel="self" type="application/rss+xml" />
	<link>http://www.eddieoneverything.com</link>
	<description>Tips &#38; tricks on things that interest me</description>
	<lastBuildDate>Wed, 11 Jan 2012 08:29:23 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Getting PHP&#8217;s print_r Function To Return A String</title>
		<link>http://www.eddieoneverything.com/programming/getting-phps-print_r-function-to-return-a-string.php</link>
		<comments>http://www.eddieoneverything.com/programming/getting-phps-print_r-function-to-return-a-string.php#comments</comments>
		<pubDate>Thu, 25 Feb 2010 22:41:42 +0000</pubDate>
		<dc:creator>eddie</dc:creator>
				<category><![CDATA[programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[print_r]]></category>

		<guid isPermaLink="false">http://www.eddieoneverything.com/?p=895</guid>
		<description><![CDATA[PHP&#8217;s print_r function is invaluable.  It prints a human-readable string representation of a variable.
It&#8217;s one of the most useful debugging features I&#8217;ve seen in any language.
I like it so much that I&#8217;ve actually written print_r mimic functions for other languages.
By default, print_r literally prints a variable to the screen.  Sometimes it&#8217;s useful to [...]]]></description>
			<content:encoded><![CDATA[<p>PHP&#8217;s print_r function is invaluable.  It prints a human-readable string representation of a variable.</p>
<p>It&#8217;s one of the most useful debugging features I&#8217;ve seen in any language.</p>
<p>I like it so much that I&#8217;ve actually written print_r mimic functions for other languages.</p>
<p>By default, print_r literally <i>prints</i> a variable to the screen.  Sometimes it&#8217;s useful to have that info not printed though.  For instance, you might want to include the print_r result in an email, or an error log, or in a special debugging frame.</p>
<p>Fortunately, print_r has this functionality built in &#8211; the function accepts an optional second argument that specifies whether you want the data printed or returned as a string.</p>
<p>To have print_r return the data as a string, include the second argument &#8220;true&#8221;:</p>
<pre name="code" class="php">
$message = print_r($myObject,true);
</pre>
<p>If you&#8217;re doing anything programmatic with the output, you may want to consider using var_export instead.  This function is largely identical to print_r, except that its output is machine parsable rather than human readable.  The usage is identical to print_r.</p>
<pre name="code" class="php">
$message = var_export($myObject,true);
</pre>
<p>All without using ob_start.  Nice!</p>
<h2  class="related_post_title">Related Posts</h2><ul class="related_post"><li><a href="http://www.eddieoneverything.com/programming/php-programming-us-state-list-functions-state-abbreviation-to-state-name-function.php" title="PHP Programming: U.S. State list functions / State abbreviation to State name function">PHP Programming: U.S. State list functions / State abbreviation to State name function</a></li><li><a href="http://www.eddieoneverything.com/articles/validating-an-email-address-with-phps-filter_var-isnt-perfect.php" title="Validating an Email Address with PHP&rsquo;s filter_var isn&rsquo;t perfect">Validating an Email Address with PHP&rsquo;s filter_var isn&rsquo;t perfect</a></li><li><a href="http://www.eddieoneverything.com/articles/how-to-scan-a-computer-for-open-ports.php" title="How to Scan a Computer for Open Ports">How to Scan a Computer for Open Ports</a></li><li><a href="http://www.eddieoneverything.com/articles/the-zen-of-taco-bell-programming-using-unix-tools-to-prevent-reinventing-the-wheel.php" title="The Zen of Taco Bell Programming &#8211; Using Unix Tools to Prevent Reinventing the Wheel">The Zen of Taco Bell Programming &#8211; Using Unix Tools to Prevent Reinventing the Wheel</a></li><li><a href="http://www.eddieoneverything.com/articles/how-to-make-phpbb3-forum-links-automatically-relnofollow.php" title="How to Make phpbb3 Forum Links Automatically rel=&#8221;nofollow&#8221;">How to Make phpbb3 Forum Links Automatically rel=&#8221;nofollow&#8221;</a></li><li><a href="http://www.eddieoneverything.com/programming/how-to-use-global-variables-from-another-file-in-a-perl-module-or-package.php" title="How To Use Global Variables From Another File In A Perl Module or Package">How To Use Global Variables From Another File In A Perl Module or Package</a></li><li><a href="http://www.eddieoneverything.com/articles/optimizing-the-google-syntax-highlighter-wordpress-plugin-even-further.php" title="Optimizing the Google Syntax Highlighter Wordpress Plugin Even Further">Optimizing the Google Syntax Highlighter Wordpress Plugin Even Further</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.eddieoneverything.com/programming/getting-phps-print_r-function-to-return-a-string.php/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

