<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>PHPDeveloper.org</title>
    <link>http://www.phpdeveloper.org</link>
    <description>Up-to-the Minute PHP News, views and community</description>
    <language>en-us</language>
    <pubDate>Tue, 21 May 2013 14:59:00 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Refulz.com: The __toString() Method - Objects as Strings]]></title>
      <guid>http://www.phpdeveloper.org/news/17523</guid>
      <link>http://www.phpdeveloper.org/news/17523</link>
      <description><![CDATA[<p>
On the Refulz.com blog there's a <a href="http://php.refulz.com/magic-methods-in-php-tostring-method/">recent post</a> introducing the __toString() magic method in PHP. This handy method allows you to define how to return an object when it's referenced as a string.
</p>
<blockquote>
We started the study of PHP magic methods by learning about <a href="http://php.refulz.com/magic-methods-in-php-__get-method/">__get() magic method</a>. [...] PHP is loosely typed language and same variable can be used or referred as string, number or object. The __toString() method is called when the code attempts to treat an object like a string. This function does not accept any arguments and should return a string.
</blockquote>
<p>
Some quick code is included showing how it works - returning a combined string made from two private class properties when the object ($obj) is echoed out. They also show multiple ways of using the method in both pre- and post-PHP 5.2.
</p>]]></description>
      <pubDate>Thu, 09 Feb 2012 09:27:19 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Micheal Kimsal's Blog: Symfony __toString() generation]]></title>
      <guid>http://www.phpdeveloper.org/news/10865</guid>
      <link>http://www.phpdeveloper.org/news/10865</link>
      <description><![CDATA[<p>
<i>Michael Kimsal</i> has <A href="http://michaelkimsal.com/blog/symfony-__tostring-generation/">pointed out</a> a small irritation when using the Symfony framework and models - an issue when using models that have relationships.
</p>
<blockquote>
If there are relations (an Author has a Book, for example). the generated forms will complain that the generated Models need a __toString() method to be used in the Form/View.  In grails, this is the case, but every domain (corresponding to a Symfony 'model') has an implicit toString() method already generated, which return the string "<domain>:<id>".  For most production work, you'll want to override it with whatever you need the string to read, but for prototyping, it's fine.
</blockquote>
<p>
He went in and modified the Symfony core to add in a __toString call that would return the object correctly. Several of the commentors agree with his frustration and some of the Symfony developers even chime in with some of the reasoning behind why it's like that.
</p>]]></description>
      <pubDate>Wed, 20 Aug 2008 11:14:50 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Zend Developer Zone: PHP Gotchas!]]></title>
      <guid>http://www.phpdeveloper.org/news/5232</guid>
      <link>http://www.phpdeveloper.org/news/5232</link>
      <description><![CDATA[<p>
The Zend Developer Zone has a <a href="http://devzone.zend.com/node/view/id/168">new post</a> for those out there struggling with the small stuff. You've got the language down and you're learning the syntax, but there's still a few things that elude your grasp. If this is you, check out <a href="http://devzone.zend.com/node/view/id/168">their list</a> of "PHP Gotchas" to see if your problem is on there.
</p>
<quote>
<i>
<p>
Call them obscure, call them pointless, call them "newb mistakes." Whatever you call them, you've more than likely been tripped up at some point in your PHP coding journey by seemingly odd or illogical behaviors of the language. With PHP being a loosely-typed language, funny things are bound to happen. 
</p>
<p>
PHP is an easy language to pick up for the casual coder--things should "just work." But not everyone comes into PHP development with a strong programming background, so here are some charming examples of ways PHP can trip you up if you aren't careful. Put on your thinking caps--here comes the science!
</p>
</i>
</quote>
<p>
Included in <a href="http://devzone.zend.com/node/view/id/168">their list</a> of common problems for budding PHP developers are things like finding a "needle" in a string "haystack", working with constants, using and/or, and the __toString functionality in PHP5.
</p>]]></description>
      <pubDate>Mon, 24 Apr 2006 12:49:58 -0500</pubDate>
    </item>
  </channel>
</rss>
