<?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, 18 Jun 2013 22:09:30 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[DZone.com: Self-Initializing Fakes in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17211</guid>
      <link>http://www.phpdeveloper.org/news/17211</link>
      <description><![CDATA[<p>
In a new post over on DZone.com <i>Giorgio Sironi</i> shows how to <a href="http://css.dzone.com/articles/self-initializing-fakes-php">create a fake</a>, an interface that mocks the interface to an external tool and provides cached results back to the calling script.
</p>
<blockquote>
We can specialize our Fake in a Self-Initializing Fake, which will provide an alternative implementation with the aid of the real one. In our Google Maps case, the Fake will use the real web service for its first response, and maintain an internal cache. This mechanism provides insurance about out-of-sync responses, and lets you enjoy the speed of unit tests after the initial warmup: if you always use the same data, no duplicate requests will be made to the external resource.
</blockquote>
<p>
He includes example code for creating a test (with <a href="http://phpunit.de">PHPUnit</a>) that loads in the information from the Google Maps web service and caches it into a private variable inside the Fake. His test fails the first time checking for a difference in the time between fetching the real version and the cached version (fails the first time, but passes after the cache is implemented).
</p>]]></description>
      <pubDate>Mon, 05 Dec 2011 10:03:53 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Working Software Blog: Escaping single and double quotes for use with XPath queries in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/16746</guid>
      <link>http://www.phpdeveloper.org/news/16746</link>
      <description><![CDATA[<p>
On the Working Software blog there's a new post showing a solution to a issue with <a href="http://www.workingsoftware.com.au/page/Escaping_single_and_double_quotes_in_XPath_queries_in_PHP">escaping quotes in XPath queries</a> that's not just an issue in PHP.
</p>
<blockquote>
I've been working with the Basecamp API to plugin our IRC bot that we use for time tracking and I'm astounded to learn that escaping single and/or double quotes for XPath queries in PHP does not have a well documented, best practices solution. In fact, it seems as though this is not peculiar to PHP. I took a look around and found this excellent article by "Kushal": <a href="http://kushalm.com/the-perils-of-xpath-expressions-specifically-escaping-quotes">http://kushalm.com/the-perils-of-xpath-expressions-specifically-escaping-quotes</a>.
</blockquote>
<p>
He's put together <a href="https://gist.github.com/1155973">his own (PHP) solution</a> to the problem - running the entire XPath query through a filtering method that splits it up, replaces the quote characters and combines it back down to a single string.
</p>]]></description>
      <pubDate>Fri, 19 Aug 2011 13:50:14 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHP 10.0 Blog: Making $$$ with PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/7543</guid>
      <link>http://www.phpdeveloper.org/news/7543</link>
      <description><![CDATA[<p>
In a <a href="http://php100.wordpress.com/2007/03/31/making-with-php/">brieft post</a> to the PHP 10.0 Blog today, <i>Stas</i> looks at a topic several PHPers out there have had to struggle with in their math-centric applications - how floats/doubles are handled in PHP.
</p>
<blockquote>
Just wanted to write about the topic discussed elsewhere - how one could do money calculations with PHP? PHP has no BCD type and no arbitrary precision float type either. And for money calculations is it important to have it very precise - accountants can not allow even single penny to slip by (remember the plot of the <a href="http://www.imdb.com/title/tt0151804/">Office Space movie</a>?)
</blockquote>
<p>
He basically says that the precision that PHP alone offers just isn't enough for some kinds of functionality. He also offers his own kind of solution proposal - switching the values back to (arbitrary-precision) integers and making all calculations in hundredth or thousandths of a cent.
</p>
<p>
Not that, according to <i>Ron</i> in the comments, there is in fact a <a href="http://ca.php.net/manual/en/ref.bc.php">BCMath extension</a> already built for PHP.
</p>]]></description>
      <pubDate>Mon, 02 Apr 2007 08:26:00 -0500</pubDate>
    </item>
  </channel>
</rss>
