News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Igor Wiedler:
Binary parsing with PHP
September 25, 2012 @ 12:17:41

Igor Wiedler has a new post to his blog showing how to work with binary data in your PHP applications a few different built-in functions including unpack and bindec.

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.

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 ord. Instead he uses "unpack", bitwise operators and bindec to work with the actual binary data of the string.

0 comments voice your opinion now!
binary parse ord unpack tutorial bindec bitwise


blog comments powered by Disqus

Similar Posts

PHPBuilder.com: Boost PHP Site Performance with Zend Framework Data Caching

CatsWhoCode.com: Getting started with CouchDB: a beginner's guide

Mike Willbanks' Blog: Integrating Gearman Into Zend Framework

php|architect: Rich Internet Applications With PHP and Flex (Part 2)

Fabien Potencier's Blog: Create your own framework... on top of the Symfony2 Components (part 1)


Community Events





Don't see your event here?
Let us know!


release interview code symfony2 unittest developer testing install laravel language community framework opinion threedevsandamaybe series introduction list podcast api refactor

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework