You are here: Re: [PHP] How to make binary strings useful? « PHP « IT news, forums, messages
Re: [PHP] How to make binary strings useful?

Posted by Chris on 10/04/04 11:07

I've written complete file parsers in PHP, and the only snag I've run
into is dealing Signed integers (and larger).


Jerry Miller wrote:

>Is there an example of the UNIX od utility written
>in PHP? Is such a useful task even possible??
>>From what I've seen of strings, they're completely
>opaque, so what good does it do to be able to read
>binary-safe strings from a file???
>

the pack() and unpack() functions are used to remove data from and
place data into binary strings.

>Even the deprecated
>(why????) $str{$inx} notation apparently results in
>another string, because trying to printf it with the
>"%02x" format always comes out with "00." (Maybe
>that's why -- it's useless!)
>
$str{$inx} does return a single character string, in order to get the
numerical value, try using ord()

>As an experienced C
>programmer, I'm finding PHP to be as counter-intuitive
>for low-level work as Perl is.
>
>I need to convert binary
>dumps of data structures into database table rows, and
>MySQL on my server doesn't support queries from C.
>
>I thought about writing a CGI script (in C) that
>would generate the hard-coded PHP output for
>each instance, but a URL that ends in ".cgi" is
>never intercepted by the PHP interpreter. Worse
>yet, the <SCRIPT LANGUAGE="" SRC="">
>that works perfectly well with JavaScript is
>likewise ignored if the language is PHP! Finally,
>I'm not aware of a Content-type such as "text/php."
>What exactly was the purpose of designing yet
>another inflexible language?!
>
>
>

Chris

http://www.php.net/pack
http://www.php.net/unpack
http://www.php.net/ord
http://www.php.net/chr

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация