<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: PHP &#8220;__toString&#8221; magic method: not so magic before 5.2.0</title>
	<atom:link href="http://www.jcinacio.com/2007/04/19/phps-__tostring-magic-method-not-so-magic-before-520/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jcinacio.com/2007/04/19/phps-__tostring-magic-method-not-so-magic-before-520/</link>
	<description>Technology, Software, Linux and System Administration</description>
	<pubDate>Fri, 12 Mar 2010 02:07:28 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: Anonymous</title>
		<link>http://www.jcinacio.com/2007/04/19/phps-__tostring-magic-method-not-so-magic-before-520/#comment-7677</link>
		<dc:creator>Anonymous</dc:creator>
		<pubDate>Thu, 15 Jan 2009 23:44:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.jcinacio.com/2007/04/19/phps-__tostring-magic-method-not-so-magic-before-520/#comment-7677</guid>
		<description>Just be use you're using the right types in the right places, in ALL code you write.

Typcasting should work here and is the right thing to do, change:

$B-&#62;add( $A );

to

$B-&#62;add( (string) $A );


If php was a typed language and you could define add() like this:

public function add(string $content)

then you would not need to explicitly cast objects as above.

relying on the php team of developers to get things right first time always leads to issues so make your code as exact as possible.</description>
		<content:encoded><![CDATA[<p>Just be use you&#8217;re using the right types in the right places, in ALL code you write.</p>
<p>Typcasting should work here and is the right thing to do, change:</p>
<p>$B-&gt;add( $A );</p>
<p>to</p>
<p>$B-&gt;add( (string) $A );</p>
<p>If php was a typed language and you could define add() like this:</p>
<p>public function add(string $content)</p>
<p>then you would not need to explicitly cast objects as above.</p>
<p>relying on the php team of developers to get things right first time always leads to issues so make your code as exact as possible.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amaroq</title>
		<link>http://www.jcinacio.com/2007/04/19/phps-__tostring-magic-method-not-so-magic-before-520/#comment-3603</link>
		<dc:creator>Amaroq</dc:creator>
		<pubDate>Fri, 21 Mar 2008 14:20:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.jcinacio.com/2007/04/19/phps-__tostring-magic-method-not-so-magic-before-520/#comment-3603</guid>
		<description>I came across this same problem. I made an image gallery with thumbnail generation and caching, and thoroughly tested it on my personal apache with PHP 5.2.3. Uploaded it to a friend's webspace on her college's server, then had to go visit some family for a week. I come back and find out that instead of displaying thumbnails that link to fullviews, it's displaying object IDs linking to their respective fullviews. I replaced all instances of $obj that were in echoes or in other strings with $obj-&#62;__toString(), and everything worked perfect.

Had I read this sooner, I would've known I didn't need to alter the actual echoes. Just the other strings.</description>
		<content:encoded><![CDATA[<p>I came across this same problem. I made an image gallery with thumbnail generation and caching, and thoroughly tested it on my personal apache with PHP 5.2.3. Uploaded it to a friend&#8217;s webspace on her college&#8217;s server, then had to go visit some family for a week. I come back and find out that instead of displaying thumbnails that link to fullviews, it&#8217;s displaying object IDs linking to their respective fullviews. I replaced all instances of $obj that were in echoes or in other strings with $obj-&gt;__toString(), and everything worked perfect.</p>
<p>Had I read this sooner, I would&#8217;ve known I didn&#8217;t need to alter the actual echoes. Just the other strings.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: admin</title>
		<link>http://www.jcinacio.com/2007/04/19/phps-__tostring-magic-method-not-so-magic-before-520/#comment-1354</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Tue, 06 Nov 2007 15:05:17 +0000</pubDate>
		<guid isPermaLink="false">http://www.jcinacio.com/2007/04/19/phps-__tostring-magic-method-not-so-magic-before-520/#comment-1354</guid>
		<description>You are right, my bad on that typo...</description>
		<content:encoded><![CDATA[<p>You are right, my bad on that typo&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mezei</title>
		<link>http://www.jcinacio.com/2007/04/19/phps-__tostring-magic-method-not-so-magic-before-520/#comment-1320</link>
		<dc:creator>mezei</dc:creator>
		<pubDate>Sun, 04 Nov 2007 17:35:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.jcinacio.com/2007/04/19/phps-__tostring-magic-method-not-so-magic-before-520/#comment-1320</guid>
		<description>I didn't run the php file, but I think this outputs:
Hello World (A) !
Hello World (B) Hello World (A) !</description>
		<content:encoded><![CDATA[<p>I didn&#8217;t run the php file, but I think this outputs:<br />
Hello World (A) !<br />
Hello World (B) Hello World (A) !</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: donald</title>
		<link>http://www.jcinacio.com/2007/04/19/phps-__tostring-magic-method-not-so-magic-before-520/#comment-106</link>
		<dc:creator>donald</dc:creator>
		<pubDate>Wed, 13 Jun 2007 10:01:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.jcinacio.com/2007/04/19/phps-__tostring-magic-method-not-so-magic-before-520/#comment-106</guid>
		<description>Nice one!

Normally I try to avoid magic functions (because I don't believe in magic), but I thought the __toString() would be useful. I was having the same problem that you are describing here. (did a google search and found your blog). 

Seems I need to update my php version on my home dev machine. Thanks for the info ;)</description>
		<content:encoded><![CDATA[<p>Nice one!</p>
<p>Normally I try to avoid magic functions (because I don&#8217;t believe in magic), but I thought the __toString() would be useful. I was having the same problem that you are describing here. (did a google search and found your blog). </p>
<p>Seems I need to update my php version on my home dev machine. Thanks for the info <img src='http://www.jcinacio.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!--sc-->

<!--end-->
