<?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 20:05:01 -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: How to add new (syntactic) features to PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/18287</guid>
      <link>http://www.phpdeveloper.org/news/18287</link>
      <description><![CDATA[<p>
<i>Nikita Popov</i> has a new post to his site looking at how you can <a href="http://nikic.github.com/2012/07/27/How-to-add-new-syntactic-features-to-PHP.html">add your own syntactic features</a> directly to PHP (requires knowledge of the C language).
</p>
<blockquote>
Several people have recently asked me where you should start if you want to add some new (syntactic) feature to PHP. As I'm not aware of any existing tutorials on that matter, I'll try to illustrate the whole process in the following. At the same time this is a general introduction to the workings of the Zend Engine. So upfront: I apologize for this overly long post.
</blockquote>
<p>
He covers the usual "life" of a PHP script, how tokenization is handled and what happens when the script is parsed, compiled and executed. Code snippets are included to show you the points to add in your own syntax item - in their case, adding an "in" operator to see if a value is in an array (a one word version of <a href="http://php.net/in_array">this</a>).
</p>]]></description>
      <pubDate>Mon, 30 Jul 2012 09:54:34 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Derick Rethans' Blog: Random Bugs and Testing RCs]]></title>
      <guid>http://www.phpdeveloper.org/news/17590</guid>
      <link>http://www.phpdeveloper.org/news/17590</link>
      <description><![CDATA[<p>
In a new post to his blog <i>Derick Rethans</i> mirrors the call made by <i>Rasmus Lerdorf</i> at this year's PHP UK Conference - <a href="http://derickrethans.nl/random-bugs-and-testing-rcs.html">get involved</a> (and help test PHP)!
</p>
<blockquote>
At the <a href="http://phpconference.co.uk/">PHP UK Conference</a> <a href="http://twitter.com/rasmus">Rasmus</a> mentioned that he wants more people contributing to PHP. There are plenty of ways how you can do that.
</blockquote>
<p>
<i>Derick</i> points out two more immediate ways you can help, one not even requiring any C knowledge:
</p>
<ul>
<li>Help test the Release Candidates (like the current PHP 5.4.0 RC8) with a call to "make test" just after your compile. 
<li>The recently added "random PHP bug" functionality that's been added to the <a href="http://bugs.php.net/random">bugs.php.net site</a>
</ul>]]></description>
      <pubDate>Mon, 27 Feb 2012 11:48:29 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Marcelo Gornstein's Blog: Sniffing in PHP using libpcap: Thank you SWIG!]]></title>
      <guid>http://www.phpdeveloper.org/news/17566</guid>
      <link>http://www.phpdeveloper.org/news/17566</link>
      <description><![CDATA[<p>
<i>Marcelo Gornstein</i> has posted a new article showing how to <a href="http://marcelog.github.com/articles/swig_php_libpcap_module_c++.html">use SWIG and libpcap</a> to sniff packets from the network directly from his PHP application.
</p>
<blockquote>
I've been wanting to try <a href="http://www.swig.org/">SWIG</a> for a long time, but never got the chance, for one thing or the other. So this weekend I've finally decided to give it a try by trying to create a php extension that access a small C++ wrapper for libpcap, so I can sniff packets directly from PHP. Just for fun (and actually because I couldn't find any active pecl extension to use libpcap, so it might as well be something useful). I've named it "<a href="https://github.com/marcelog/SimplePcap">SimplePcap</a>".
</blockquote>
<p>
He includes both the sample code showing the extension's usage and an example of the output from his local "eth0" device. His PHP script uses SWIG to interface with the pcap_t/Packet class structure via <A href="https://github.com/marcelog/SimplePcap/blob/master/SimplePcap.i">this interface file</a> and typemap.
</p>
<blockquote>
SWIG is really great. I just did some C++ code and then worried about how to integrate it to PHP. Althought it seems that you really need lots of experience with it to actually do more advanced things in the right way. [...] So I guess that sometimes it's more productive to just make the PHP extension than using SWIG. But if you want your code to be run in many languages, this is definitely an excellent library to try!
</blockquote>]]></description>
      <pubDate>Tue, 21 Feb 2012 10:13:34 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: PHP's Quest for Performance: From C to hhvm]]></title>
      <guid>http://www.phpdeveloper.org/news/17280</guid>
      <link>http://www.phpdeveloper.org/news/17280</link>
      <description><![CDATA[<p>
On PHPMaster.com today there's a new post from <i>Matthew Turland</i> talking about PHP's <a href="http://phpmaster.com/phps-quest-for-performance/">quest for performance</a> and some of the recent advancements that have made better performing applications even more possible.
</p>
<blockquote>
While it's sufficient for many users, as PHP sees increased use by large sites like Wikipedia and Facebook, the ability to serve more requests on fewer servers becomes increasingly important. Some efforts have been made in this area in the last few years, both within and outside the PHP internals team. However, understanding exactly what's going on requires a bit of background both in history and concepts.
</blockquote>
<p>
He goes through some of the origins of the PHP language (from the early days with <i>Rasmus Lerdorf</i>) to the fact that the PHP language itself is interpreted - complete with some of the overhead that comes with that. He also mentions various projects that have tried to compile PHP back down to C to increase performance like <a href="http://www.roadsend.com/home/index.php">Roadsend</a>, <a href="https://www.facebook.com/note.php?note_id=280583813919">HipHop</a> and, most recently, the <a href="https://www.facebook.com/notes/facebook-engineering/the-hiphop-virtual-machine/10150415177928920">HipHop virtual machine</a> from Facebook.
</p>]]></description>
      <pubDate>Tue, 20 Dec 2011 08:40:58 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Nikic's Blog: How big are PHP arrays (and values) really? (Hint: BIG!)]]></title>
      <guid>http://www.phpdeveloper.org/news/17270</guid>
      <link>http://www.phpdeveloper.org/news/17270</link>
      <description><![CDATA[<p>
In <a href="http://nikic.github.com/2011/12/12/How-big-are-PHP-arrays-really-Hint-BIG.html">this recent blog post</a> <i>nikic</i> takes an in-depth look at <a href="http://nikic.github.com/2011/12/12/How-big-are-PHP-arrays-really-Hint-BIG.html">how large PHP arrays really are</a> - how memory is used in the creation and management of these handy PHP variable types.
</p>
<blockquote>
In this post I want to investigate the memory usage of PHP arrays (and values in general) using the following script as an example, which creates 100000 unique integer array elements and measures the resulting memory usage. [...] How much would you expect it to be? [...] Now try and run the above code. <a href="http://codepad.viper-7.com/pjB3Wm">You can do it online if you want</a>. This gives me 14649024 bytes. Yes, you heard right, that's 13.97 MB - eightteen times more than we estimated.
</blockquote>
<p>
He goes into the details of PHP's memory management and breaks it down into the different totals (for 64 bit and 32 bit OSes) and details on each - zvalue_value, zvalue, cycles collector, Zend MM allocator and the buckets used to isolate one array (hash table/dictionary) from another. 
</p>
<blockquote>
What does this tell us? PHP ain't C. That's all this should tell us. You can't expect that a super dynamic language like PHP has the same highly efficient memory usage that C has. You just can't.
</blockquote>]]></description>
      <pubDate>Fri, 16 Dec 2011 10:28:39 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[Kristina Chodorow's Blog: Writing a PHP Extension (Four Part Series)]]></title>
      <guid>http://www.phpdeveloper.org/news/16737</guid>
      <link>http://www.phpdeveloper.org/news/16737</link>
      <description><![CDATA[<p>
<i>Kristina Chodorow</i> has posted a four part series of articles to her blog that shares some of her experiences in developing an extension for PHP (on C/C++). It walks you through the entire process - from the basic "hello world" out to working with more complex data structures.
</p>
<blockquote>
A PHP extension allows you to connect almost any C/C++ code you want to PHP. This is a 4-part tutorial on how to write an extension. [...] Almost all of the code examples in this tutorial are available on <a href="https://github.com/kchodorow/rlyeh">Github</a>.
</blockquote>
<p>The parts of the series cover:</p>
<ul>
<li><a href="http://www.snailinaturtleneck.com/blog/2011/08/11/php-extensions-made-eldrich-installing-php/">setting up a PHP environment</a>
<li>creating a <a href="http://www.snailinaturtleneck.com/blog/?p=1520">first "hello world" extension</a>
<li><a href="http://www.snailinaturtleneck.com/blog/?p=1521">working with the PHP C API</a>
<li><a href="http://www.snailinaturtleneck.com/blog/?p=1522">creating PHP objects in C</a> (classes)
</ul>
<p>
Each step comes with some good explanation, code samples and some advice on common tasks and pitfalls along the way.
</p>]]></description>
      <pubDate>Thu, 18 Aug 2011 10:29:37 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Kevin Schroeder's Blog: What to make of TIOBE's PHP results]]></title>
      <guid>http://www.phpdeveloper.org/news/15993</guid>
      <link>http://www.phpdeveloper.org/news/15993</link>
      <description><![CDATA[<p>
<i>Kevin Schroeder</i> has <a href="http://www.eschrade.com/page/what-to-make-of-tiobe-php/">some of his own thoughts</a> on the recent results of the TIOBE index ranking the popularity of programming languages. PHP has slopped down two spots, replaced by Python and C++. He looks at the data TIOBE has to back it up and can't seem to find a reason why.
</p>
<blockquote>
I decided to take a look and see what was going on behind the scenes by reading on the <a href="http://www.tiobe.com/index.php/content/paperinfo/tpci/tpci_definition.htm">index definition</a> to see if I could understand what happened. After reading through the definition I still don't know what happened, or even why it happened.
</blockquote>
<p>
He goes through how the index data is created - search results from the top 6 hits in Alexa for each language result - and how he, basically, found nothing out of the ordinary. He points out that, because of inconsistencies like this, the TIOBE index shouldn't be regarded as much more than a loose guide. Since it's based on hard-coded search strings, it'll never be a true judge of "popularity" overall.
</p>]]></description>
      <pubDate>Thu, 03 Mar 2011 12:20:29 -0600</pubDate>
    </item>
    <item>
      <title><![CDATA[David Parra's Blog: Calling Conventions '" when you need to know C to understand PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/12824</guid>
      <link>http://www.phpdeveloper.org/news/12824</link>
      <description><![CDATA[<p>
<i>David Parra</i> has <a href="http://blog.experimentalworks.net/2009/07/calling-conventions-when-you-need-to-know-c-to-understand-php/">a suggestion</a> for PHP developers out there - it might be beneficial to learn some C so you know what's going on.
</p>
<blockquote>
I think most of the people using PHP wonder from time to time about particular behavior of the language. [...] But lately I stumbled over a nice one. It looked like a bug in PHP, but turns out to be an interesting, curious, part of the C-language.
</blockquote>
<p>
He gives an example of a case where an error message (as a result of E_ALL error reporting) shows evaluation of certain variables in a different order than anticipated. As it turns out, the difference was in the order of the parameters in the C code of PHP (different on SPARC versus x86 systems).
</p>]]></description>
      <pubDate>Tue, 07 Jul 2009 12:03:24 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Zend Developer Zone: Wrapping C++ Classes in a PHP Extension]]></title>
      <guid>http://www.phpdeveloper.org/news/12393</guid>
      <link>http://www.phpdeveloper.org/news/12393</link>
      <description><![CDATA[<p>
On the Zend Developer Zone a <a href="http://devzone.zend.com/article/4486-Wrapping-C-Classes-in-a-PHP-Extension">new tutorial</a> has been posted looking at taking your pre-existing C++ functionality and wrapping it in a PHP extension to be used directly in your code.
</p>
<blockquote>
In this tutorial I am going to walk you through creating a PHP extension called "vehicles" which will expose a single class called "Car" (obviously in the real-world, your extensions will expose many classes, but I'm trying to keep things simple). The extension will be built for PHP 5. I am only going to give instructions for building the extension in a UNIX-like environment, although most of what I cover should apply to Windows extension development as well.
</blockquote>
<p>
The tutorial walks you through everything - how the file layout should look, making a build system, the contents of his files (the sample extension lets you do things to the Car like shift gears and brake) and how to combine the C++ code with the build process to create a shared module you can include right in your php.ini.
</p>]]></description>
      <pubDate>Thu, 23 Apr 2009 10:21:50 -0500</pubDate>
    </item>
  </channel>
</rss>
