<?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, 19 Jun 2013 14:23:26 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Sherif Ramadan: A Closer Look Into PHP Arrays: What You Don't See]]></title>
      <guid>http://www.phpdeveloper.org/news/18670</guid>
      <link>http://www.phpdeveloper.org/news/18670</link>
      <description><![CDATA[<p>
In a new post <i>Sherif Ramadan</i> takes an <a href="http://sheriframadan.com/2012/10/a-closer-look-into-php-arrays/">in-depth look at PHP arrays</a> and what happens behind the scenes when they're put to use. 
</p>
<blockquote>
PHP is one unique language where the array data type has been highly generalized to suit a very broad set of use cases. [...] I'm going to share with you some of the underlying details of how the PHP array data type works, why it works the way that it does, how it's different from other languages, and what behaviors the PHP array has that you may not be fully aware of.
</blockquote>
<p>
He starts with a section looking at what arrays actually are in PHP (and how they compare to the lower level C arrays). He gives a C-based array example and shows how it's <a href="http://sheriframadan.com/wp-content/uploads/2012/10/c-array.png">stored in memory</a>. He points out how PHP arrays are different from other languages and shows the C code that works behind the scenes to create the array (actually a hashtable). He gets into a detailed explanation of the iteration of arrays including some basic benchmarks of some of the various methods and gets more in-depth with <a href="http://php.net/foreach">foreach</a> (including subarrays and arrays containing references).
</p>]]></description>
      <pubDate>Mon, 29 Oct 2012 11:43:33 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Nikita Popov's Blog: Understanding PHP's internal array implementation (Part 4)]]></title>
      <guid>http://www.phpdeveloper.org/news/17749</guid>
      <link>http://www.phpdeveloper.org/news/17749</link>
      <description><![CDATA[<p>
<i>Nikita Popov</i> has posted the <a href="http://nikic.github.com/2012/03/28/Understanding-PHPs-internal-array-implementation">fourth part</a> of the "PHP's Source Code for PHP Developers" series he and <i>Anthony Ferrara</i> have been posting. In this latest article in the series, <i>Nikita</i> looks specifically at PHP's array implementation and how it's handed "behind the scenes".
</p>
<blockquote>
Welcome back to the fourth part of the "PHP's Source Code for PHP Developers" series, in which we'll cover how PHP arrays are internally represented and used throughout the code base.
</blockquote>
<p>
He starts with an obvious foundation: "everything's a hash table" (even properties, classes and yes, arrays). He describes what a hash table is and talks about two of the most commonly used versions of it in the PHP source - HashTable and Bucket. He gets into their usage a bit and compares this to the corresponding PHP code that uses a standard array.
</p>]]></description>
      <pubDate>Thu, 29 Mar 2012 09:16:02 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHP.net: PHP 5.3.10 Released (Security Fix - Recommended Upgrade)]]></title>
      <guid>http://www.phpdeveloper.org/news/17492</guid>
      <link>http://www.phpdeveloper.org/news/17492</link>
      <description><![CDATA[<p>
The PHP development team has <a href="http://www.php.net/index.php#id2012-02-02-1">officially announced</a> the release of the latest version of PHP in the 5.3.x series - <a href="http://www.php.net/downloads.php">PHP 5.3.10</a>:
</p>
<blockquote>
The PHP development team would like to announce the immediate availability of PHP 5.3.10. This release delivers a critical security fix. [...] Fixed arbitrary remote code execution vulnerability reported by Stefan Esser, CVE-2012-0830.
</blockquote>
<p>
It is highly recommended that users upgrade to this latest version to avoid falling victim to <a href="http://thexploit.com/sec/critical-php-remote-vulnerability-introduced-in-fix-for-php-hashtable-collision-dos/">this recently introduced bug</a> relating to the new "max_input_vars" setting added to protect from the overflow issue <a href="http://phpdeveloper.org/news/17322">recently brought up</a> in the PHP community.
</p>]]></description>
      <pubDate>Fri, 03 Feb 2012 08:01:29 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Nikita Popov's Blog: Supercolliding a PHP array]]></title>
      <guid>http://www.phpdeveloper.org/news/17322</guid>
      <link>http://www.phpdeveloper.org/news/17322</link>
      <description><![CDATA[<p>
In a new post to his blog <i>Nikita Popov</i> talks about a little <a href="http://nikic.github.com/2011/12/28/Supercolliding-a-PHP-array.html">trick with inserting values into arrays</a> that can make it take a lot longer than it should (because of how PHP stores its array values in hashtables).
</p>
<blockquote>
PHP internally uses hashtables to store arrays. The above creates a hashtable with 100% collisions (i.e. all keys will have the same hash). [...] Because every hash function has collisions this C array doesn't actually store the value we want, but a linked list of possible values. [...] Normally there will be only a small number of collisions, so in most cases the linked list will only have one value. But the [included script] creates a hash where all elements collide.
</blockquote>
<p>
He explains why it works, noting that it's relatively simple to do in PHP because of how it applies a table mask. The slowness comes in when PHP is forced to go through the entire list when it tries to insert. Because of this issue, there's the potential for a Denial of Service attack that could potentially take a server down. There's <a href="http://svn.php.net/viewvc?view=revision&revision=321038">a fix already in place</a> for the problem, though, so keep an eye out for the next release (that will include a max_input_vars setting to prevent it).
</p>]]></description>
      <pubDate>Thu, 29 Dec 2011 12:15:30 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Johannes Schluter's Blog: HashTables]]></title>
      <guid>http://www.phpdeveloper.org/news/15000</guid>
      <link>http://www.phpdeveloper.org/news/15000</link>
      <description><![CDATA[<p>
<i>Johannes Schluter</i> has <a href="http://schlueters.de/blog/archives/142-HashTables.html">a new post</a> to his blog on another PHP internals related topic - hashtables.
</p>
<blockquote>
While preparing my "<a href="http://phpconference.nl/schedule/talks#phphood">PHP Under The Hood</a>" talk for the Dutch PHP Conference there was a question on IRC about <a href="http://php.net/extension_loaded">extension_loaded</a>() being faster than <a href="http://php.net/function_exists">function_exists</a>(), which might be strange as both of them are simple hash lookups and a hash lookup is said to be O(1). I started to write some slides for it but figured out that I won't have the time to go through it during that presentation, so I'm doing this now.
</blockquote>
<p>
He talks about array storage (a "real" array), numeric and string-based keys, the internals of how each is stored and how the differences make the one function faster than the other (hint: it's all <a href="http://schlueters.de/~johannes/php/collisions.txt">about collisions</a>).
</p>]]></description>
      <pubDate>Mon, 23 Aug 2010 08:58:43 -0500</pubDate>
    </item>
  </channel>
</rss>
