<?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 03:43:28 -0500</pubDate>
    <ttl>30</ttl>
    <item>
      <title><![CDATA[Igor Wiedler: Binary parsing with PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/18518</guid>
      <link>http://www.phpdeveloper.org/news/18518</link>
      <description><![CDATA[<p>
<i>Igor Wiedler</i> has a new post to his blog showing how to <a href="https://igor.io/2012/09/24/binary-parsing.html">work with binary data</a> in your PHP applications a few different built-in functions including <a href="http://php.net/unpack">unpack</a> and <a href="http://php.net/bindec"> bindec</a>.
</p>
<blockquote>
Binary operations in PHP are a bit strange. Since PHP was originally a templating layer for C code, it still has many of those C-isms. Lots of the function names map directly to C-level APIs, even if they work a bit differently sometimes. For example, PHP's strlen maps directly to STRLEN(3), and there are countless examples of this. However, as soon as it comes to dealing with binary data, things suddenly become very different.
</blockquote>
<p>
He starts off looking at "the C way" to unpack a string (getting the ASCII values of each character) and shows how *not* to do it in PHP with <a href="http://php.net/ord">ord</a>. Instead he uses "unpack", bitwise operators and bindec to work with the actual binary data of the string.
</p>]]></description>
      <pubDate>Tue, 25 Sep 2012 12:17:41 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[PHPMaster.com: 5 Inspiring (and Useful) PHP Snippets]]></title>
      <guid>http://www.phpdeveloper.org/news/18162</guid>
      <link>http://www.phpdeveloper.org/news/18162</link>
      <description><![CDATA[<p>
On PHPMaster.com there's a new tutorial that <a href="http://phpmaster.com/5-inspiring-and-useful-php-snippets/">shares some useful PHP snippets</a> that you could use in your development.
</p>
<blockquote>
"X PHP Snippets" type articles abound on the Internet, so why write another one? Well, let's face it… the PHP snippets in them are generally lame. Snippets that generating a random string or return $_SERVER["REMOTE_ADDR"] for the IP Address of a client really aren't that interesting and are of modest usefulness. Instead, here's five snippets that you'll no doubt find interesting and useful, presented along with the problems that inspired them. I hope the creativity in many of them inspire you to write better and more creative code in your own day-to-day endeavors.
</blockquote>
<p>Their "five tips" are about:</p>
<ul>
<li>Generating CSV files from an array of data
<li>Autoloading classes (in a PSR-0 way)
<li>Parsing data with the <a href="http://php.net/unpack">unpack</a> function
<li>Templating in HTML (creating a "View" object)
<li>Using file_get_contents as a cURL Alternative
</ul>]]></description>
      <pubDate>Mon, 02 Jul 2012 10:58:45 -0500</pubDate>
    </item>
    <item>
      <title><![CDATA[Sameer Borate's Blog: Unpacking binary data in PHP]]></title>
      <guid>http://www.phpdeveloper.org/news/15170</guid>
      <link>http://www.phpdeveloper.org/news/15170</link>
      <description><![CDATA[<p>
<i>Sameer Borate</i> has <a href="http://www.codediesel.com/php/unpacking-binary-data/">a new post</a> to his blog today talking about a method for unpacking binary data directly in PHP - specifically in working with images.
</p>
<blockquote>
To set the stage we will start with a programming problem, this will keep the discussion anchored to a relevant context. The problem is this : We want to write a function that takes a image file as an argument and tells us whether the file is a GIF image; irrelevant with whatever the extension the file may have. We are not to use any GD library functions.
</blockquote>
<p>
He shows how to use the <a href="http://php.net/manual/en/function.unpack.php">unpack</a> function to open up the file and pull out the raw data - including the header information that tells you what kind of file it is you're working with. There's also an example of unpacking the header contents and grabbing things like height, width and the aspect of the image.
</p>]]></description>
      <pubDate>Wed, 22 Sep 2010 10:45:52 -0500</pubDate>
    </item>
  </channel>
</rss>
