<?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>Wed, 23 May 2012 11:00:09 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Mike Purcell's Blog: PHPUnit - Upgrade - Convert assertType to assertInternalType]]></title>
      <guid>http://www.phpdeveloper.org/news/17982</guid>
      <link>http://www.phpdeveloper.org/news/17982</link>
      <description><![CDATA[<p>
In <a href="http://melikedev.com/2012/05/18/phpunit-upgrade-convert-asserttype-to-assertinternaltype/">this quick post</a> to his blog, <i>Mike Purcell</i> mentions the deprecation of the "assertType" assertion and includes some code you can add to correct the issue in your tests.
</p>
<blockquote>
We recently upgraded phpunit from a very old version to the current 3.6.x version (at time of writing). During the upgrade I noticed that assertType is no longer supported in many of our tests which were testing if something was a string, an array, or an object. So I had to write a quick script to update assertType to assertInternalType and figured I would post it for others if they needed to do the same.
</blockquote>
<p>
The code goes into each of your tests (recursively) and finds the places where the "assertType" assertion is used and replaces it with its newer cousin "assertIntrnalType". 
</p>]]></description>
      <pubDate>Mon, 21 May 2012 09:56:59 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Joseph Scott's Blog: Why PHP Strings Equal Zero]]></title>
      <guid>http://www.phpdeveloper.org/news/17679</guid>
      <link>http://www.phpdeveloper.org/news/17679</link>
      <description><![CDATA[<p>
<i>Joseph Scott</i> has a new post to his blog looking at "<a href="http://josephscott.org/archives/2012/03/why-php-strings-equal-zero/">why PHP strings equal zero</a>" - that when you use the "==" operator on a string to compare to zero, it's true.
</p>
<blockquote>
The issue of PHP strings equaling zero has come up a few times recently. [...] Running that will display Equals zero!, which at first glance probably doesn't make much sense. So what is going on here?
</blockquote>
<p>
He gets into the specifics of what's happening - a bit of type jugging, less strict comparison since it's the "==" versus "===" and how the <a href="http://php.net/manual/en/language.types.string.php">PHP manual</a> talks about strings being converted to numbers. 
</p>
<blockquote>
While I still think it is odd that the string gets cast as an integer instead of the other way around, I don't think this is a big deal. I can't recall a single time where I've ever run into this issue in a PHP app. I've only seen it come up in contrived examples like the ones above.
</blockquote>]]></description>
      <pubDate>Thu, 15 Mar 2012 09:47:49 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Gonzalo Ayuso's Blog: How to use eval() without using eval() in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17665</guid>
      <link>http://www.phpdeveloper.org/news/17665</link>
      <description><![CDATA[<p>
In <a href="http://gonzalo123.wordpress.com/2012/03/12/how-to-use-eval-without-using-eval-in-php/">this new post</a> <i>Gonzalo Ayuso</i> talks about "using eval without using eval" in PHP applications - executing PHP code without having to use the <a href="http://php.net/eval">eval</a> function to do it.
</p>
<blockquote>
Yes I know. Eval() is evil. If our answer is to use <a href="http://php.net/manual/en/function.eval.php">eval()</a> function, we are probably asking the wrong question. When we see an eval() function all our coding smell's red lights start flashing inside our mind. Definitely it's a bad practice. But last week I was thinking about it. How can I eval raw PHP code without using the eval function, and I will show you my outcomes.
</blockquote>
<p>
He includes some sample code showing a basic script with a class and a loop executing normally, then an "eval version" that puts it all in a string and executes it. He offers a different method - not an ideal one since it requires being able to write to the local file system, but prevents the need for eval - writing the PHP code to a temporary file and using a "fake eval" to <a href="htttp://php.net/include">pull it in</a>.
</p>]]></description>
      <pubDate>Tue, 13 Mar 2012 10:09:52 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Brandon Savage's Blog: An XSS Vulerability In The Making]]></title>
      <guid>http://www.phpdeveloper.org/news/17640</guid>
      <link>http://www.phpdeveloper.org/news/17640</link>
      <description><![CDATA[<p>
<i>Brandon Savage</i> has a new post to his blog about what he calls a <a href="http://www.brandonsavage.net/an-xss-vulerability-in-the-making/">XSS vulnerability in the making</a>, something to watch out for when you're doing validation in PHP involving the possibility of numbers as strings.
</p>
<blockquote>
Back in September, <a href="https://crash-stats.mozilla.org/">Socorro</a> received a <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=689675">security bug</a> relating to the method we were using for processing inputs for the duration of certain reports. The vulnerability included a proof of concept, with an alert box popping up on production when the link was followed. [...] I was quite surprised at the root cause of the vulnerability. We had opted to compare the incoming data against a known set of valid values - a common practice when whitelisting certain inputs. [...] As expected, when this [example] code is tested, a string of '3' and an integer of 3 work equally well, and a string of '5' and an integer of 5 fail equally. 
</blockquote>
<p>
This automatic casting that PHP does internally caused another issue as well - if the string passed in even started with a valid number from their whitelist set, it still passed.
</p>
<blockquote>
At first we thought this surely had to be a bug in PHP. However, Laura Thomson told me "If comparing two values, type juggling is performed first, which means that the string is converted to a number. This is done by <a href="http://us2.php.net/manual/en/language.types.string.php#language.types.string.conversion">taking the first number found in the string</a>. So this may be confusing/a quirk/a gotcha, but it isn't a bug." And she's right: this isn't a bug per se, but it's certainly an interesting "gotcha."
</blockquote>]]></description>
      <pubDate>Wed, 07 Mar 2012 12:02:46 -0600</pubDate>
    </item>
    <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[Project: Patchwork-UTF8 - UTF8 Support for PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17458</guid>
      <link>http://www.phpdeveloper.org/news/17458</link>
      <description><![CDATA[<p>
<i>Nicolas Grekas</i> has shared another tool that he's pulled out of his "Patchwork" framework to make it a stand-alone tool: the <a href="https://github.com/nicolas-grekas/Patchwork-UTF8">Patchwork-UTF8 helper</a> that provides matching functions to those PHP already has for regular strings, but a little smarter to work with UTF8 correctly.
</p>
<blockquote>
The PatchworkUtf8 class implements the quasi complete set of string functions that need UTF-8 grapheme clusters awareness. These functions are all static methods of the PatchworkUtf8 class. The best way to use them is to add a use PatchworkUtf8 as u; at the beginning of your files, then when UTF-8 awareness is required, prefix by u:: when calling them.
</blockquote>
<p>
In <a href="https://github.com/nicolas-grekas/Patchwork-UTF8/blob/master/README.md">the README</a> for the tool he talks about the functions included in the current release that match PHP's string functions as well as some additional methods like "isUtf8", "bestFit" and "strtocasefold". It relies on the mbstring, iconv and intl extensions being installed, and if they aren't, it falls back to other functionality (list of those methods included).
</p>]]></description>
      <pubDate>Fri, 27 Jan 2012 11:38:40 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Nikita Popov's Blog: Disproving the Single Quotes Performance Myth]]></title>
      <guid>http://www.phpdeveloper.org/news/17369</guid>
      <link>http://www.phpdeveloper.org/news/17369</link>
      <description><![CDATA[<p>
In <a href="http://nikic.github.com/2012/01/09/Disproving-the-Single-Quotes-Performance-Myth">this new post</a> to his blog <i>Nikita Popov</i> aims to dispel the popular micro-optimization myth of using single quotes over double quotes for a performance boost.
</p>
<blockquote>
If there is one PHP related thing that I really hate, then it is definitely the Single Quotes Performance Myth. [...] Let's do a random Google search for <a href='https://www.google.com/search?q=php+single+quotes+performance'>"PHP single quotes performance"</a>: <a href='http://stackoverflow.com/questions/482202/is-there-a-performance-benefit-single-quote-vs-double-quote-in-php'>You</a> <a href='http://stackoverflow.com/questions/3316060/single-quotes-or-double-quotes-for-variable-concatenation'>will</a> <a href='http://atomized.org/2005/04/php-performance-best-practices/'>get</a> <a href='https://github.com/fabpot/Twig/issues/407'>many</a> <a href='http://classyllama.com/development/php/php-single-vs-double-quotes/'>results</a> telling you that single quotes are faster than double quotes and that string interpolation is much slower than string concatenation. Most of them advise to use single quotes and concatenation to improve the performance of your application. Let's be clear here: <b>This is pointless.</b>
</blockquote>
<p>
He did some benchmarking of his own to see how the myth would hold up and, as it turns out, it doesn't - "There is none". His proof compares two strings, one normal single-quoted and the other a double-quoted, and the opcodes they generate. They end up exactly the same. Since it's the opcodes that matter, he recommends using something like <a href="http://php.net/manual/en/book.apc.php">APC</a> if you're really worried about the performance. He also includes an example using the <a href="http://php.net/token_get_all">token_get_all</a> function of PHP to see how fast the strings run through the lexer too (again, almost no difference).
</p>
<p>
As an added bonus, he also throws in a bit about string concatenation versus string interpolation with some <a href="http://codepad.viper-7.com/p4aUGN">benchmarking scripts</a> and results of their own.
</p>]]></description>
      <pubDate>Tue, 10 Jan 2012 09:47:55 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Mark Story's Blog: New errors in PHP 5.4]]></title>
      <guid>http://www.phpdeveloper.org/news/17324</guid>
      <link>http://www.phpdeveloper.org/news/17324</link>
      <description><![CDATA[<p>
In <a href="http://mark-story.com/posts/view/new-errors-in-php-5-4">this quick new post</a> to his blog <i>Mark Story</i> talks about two new errors he ran across when upgrading his installation to PHP 5.4, both showing up under E_ALL.
</p>
<blockquote>
I've been running the PHP5.4 RC builds for the last few months, and there are some interesting changes in the upcoming PHP release. On top of all the great new features coming in PHP5.4. After updating to PHP5.4-RC4, a few things that used to not trigger errors and silently do the wrong thing, now trigger notices or warnings.
</blockquote>
<p>
The two he mentions deal with a new warning on illegal string offsets and the other about string offsets ("Notice: String offset cast occurred"). You can find out about more changes in the PHP 5.4 series in <a href="http://php.net/releases/">the various Changelogs</a> for each Release Candidate and beta release.
</p>]]></description>
      <pubDate>Fri, 30 Dec 2011 08:30:45 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: String Handling Functions]]></title>
      <guid>http://www.phpdeveloper.org/news/17304</guid>
      <link>http://www.phpdeveloper.org/news/17304</link>
      <description><![CDATA[<p>
On PHPMaster.com today <i>James Appleyard</i> has put tother a tutorial for the beginners out there about <a href="http://phpmaster.com/string-handling-functions/">working with strings in PHP</a>, using the huge list of built-in functions to work with your values.
</p>
<blockquote>
PHP has a vast selection of built-in string handling functions that allow you to easily manipulate strings in almost any possible way. [...]  There is no way I can cover every string function in one article, and besides, that is what the PHP manual is for! But what I will do is show how to work with some of the most commonly used string handling functions that you should know. After this, you'll be working with strings as well as any concert violinist!
</blockquote>
<p>
He shows how to use functions to: change the case of string, remove extra whitespace, get the length, slicing them up and doing replacing on some certain characters. You can find more information on these and the complete list of string functions in PHP in <a href="http://us2.php.net/strings">the manual</a>.
</p>]]></description>
      <pubDate>Mon, 26 Dec 2011 15:38:56 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Mrinmoy Ghoshal's Blog: Concept of Strings:PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/17222</guid>
      <link>http://www.phpdeveloper.org/news/17222</link>
      <description><![CDATA[<p>
If you're new to the PHP language and are looking for the full scoop on working with the string datatype, look no further than <a href="http://myfairywren.wordpress.com/2011/12/01/concept-of-stringsphp/">this new post</a> from <i>Mrinmoy Ghoshal</i>. It's an excellent (and quite complete) resource for just about everything involving <a href="http://www.php.net/manual/en/language.types.string.php">strings</a> in PHP.
</p>
<blockquote>
A <a href="http://www.php.net/manual/en/language.types.string.php">string</a> is series of characters, where a character is the same as a byte. This means that PHP only supports a 256-character set, and hence does not offer native Unicode support. See <a href="http://www.php.net/manual/en/language.types.string.php#language.types.string.details">details of the string type</a>.
</blockquote>
<p>
The tutorial is broken up into different sections for easier consumption:
</p>
<ul>
<li>Single quoted
<li>Double quoted
<li>Heredoc
<li>Nowdoc
<li>Variable parsing
<li>String access and modification by character
<li>Useful functions and operators
<li>Converting to string
<li>String conversion to numbers
<li>Details of the String Type
</ul>]]></description>
      <pubDate>Wed, 07 Dec 2011 09:56:37 -0600</pubDate>
    </item>
  </channel>
</rss>

