<?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>Sat, 25 May 2013 12:21:05 -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>
  </channel>
</rss>
