Re: [PHP] How to make binary strings useful?
Jerry Miller wrote: Is there an example of the UNIX od utility written in PHP? I dunno. Goodle for PHP octal dump Is such a useful task even possible?? Certainly it's possible, though I'm not sure why you wouldn't just USE the existing 'od' utility. 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??? Strings are strings in PHP. They're not bytes thinly disguised as strings by some declarative fiat of the programmer. If you want to convert a string to an integer, then you have to use the http://php.net/ord function to do that. You can then use functions to convert to binary, hex, octal etc. Even the deprecated (why) $str{$inx} notation apparently results in You'd have to read the PHP-Developer list to find out what the rationale for deprecating that feature was. Perhaps the confusion that arose from people thinking strings where arrays, since the syntax for array indexing was the same wasn't worth the benefit of being able to use [] on a string. another string, because trying to printf it with the %02x format always comes out with 00. (Maybe that's why -- it's useless!) Actually, I've always found [] access to a string quite useful. But since I read the manual, I knew I just got a string which happened to be one character in length from that. As an experienced C programmer, I'm finding PHP to be as counter-intuitive for low-level work as Perl is. So write your utility in C. [shrug] I need to convert binary dumps of data structures into database table rows, and MySQL on my server doesn't support queries from C. Okay, but don't wade into PHP programming pretending that it's C just because the syntax has a surface resemblance to 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 Then your web server PHP CGI configuration is borked. Fix it. yet, the SCRIPT LANGUAGE= SRC= that works perfectly well with JavaScript is likewise ignored if the language is PHP! Finally, Actually, you can use SCRIPT LANGUAGE=PHP on the server to have it parse PHP, but PHP is always parsed on the SERVER, never on the client, so the browser is not going to be able to do much intelligent with SCRIPT LAGNGUAGE=PHP SRC=xxx I'm not aware of a Content-type such as text/php. What exactly was the purpose of designing yet another inflexible language?! If you want to send PHP source code to the browser, you'd send it as text/plain Other than that, PHP is SERVER-SIDE and sending text/php would be silly, as browsers don't have PHP interpreters (and likely never will). Basically, as far as I can tell, you've waded into PHP pretending that it's C and now are pissed off because it's not C. Well duh! Why not spend a little time to read the [bleep] manual?! http://php.net/manual/ Just focus on the first few sections, up to the point where it starts listing all the extensions and functions. An experienced C programmer could probably read through all that in, what, an hour or two? You would have saved yourself a GREAT DEAL of frustration, and wouldn't have wasted so much time on your rant and the replies. Good Luck! http://php.net/manual/ -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] How to make binary strings useful?
I need to convert binary dumps of data structures into database table rows, and MySQL on my server doesn't support queries from C. Errr, how can that be? AFAIK the mySQL extension of PHP is ostensibly a wrapper for the mySQL C libraries. If you have mySQL and PHP installed then I can't see any reason why you shouldn't be able to write these queries in C HTH, Mikey -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to make binary strings useful?
Richard Lynch wrote: Jerry Miller wrote: Is there an example of the UNIX od utility written in PHP? I dunno. Goodle for PHP octal dump Is such a useful task even possible?? Certainly it's possible, though I'm not sure why you wouldn't just USE the existing 'od' utility. 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??? Strings are strings in PHP. They're not bytes thinly disguised as strings by some declarative fiat of the programmer. If you want to convert a string to an integer, then you have to use the http://php.net/ord function to do that. You can then use functions to convert to binary, hex, octal etc. Even the deprecated (why) $str{$inx} notation apparently results in You'd have to read the PHP-Developer list to find out what the rationale for deprecating that feature was. Perhaps the confusion that arose from people thinking strings where arrays, since the syntax for array indexing was the same wasn't worth the benefit of being able to use [] on a string. I have no idea why everyone here believes that syntax is deprecated, since I don't believe it actually is! The deprecated syntax was the one with *square* brackets $string[3] instead of $string{3} etc. another string, because trying to printf it with the %02x format always comes out with 00. (Maybe that's why -- it's useless!) Actually, I've always found [] access to a string quite useful. But since I read the manual, I knew I just got a string which happened to be one character in length from that. As an experienced C programmer, I'm finding PHP to be as counter-intuitive for low-level work as Perl is. So write your utility in C. [shrug] I need to convert binary dumps of data structures into database table rows, and MySQL on my server doesn't support queries from C. Okay, but don't wade into PHP programming pretending that it's C just because the syntax has a surface resemblance to 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 Then your web server PHP CGI configuration is borked. Fix it. yet, the SCRIPT LANGUAGE= SRC= that works perfectly well with JavaScript is likewise ignored if the language is PHP! Finally, Actually, you can use SCRIPT LANGUAGE=PHP on the server to have it parse PHP, but PHP is always parsed on the SERVER, never on the client, so the browser is not going to be able to do much intelligent with SCRIPT LAGNGUAGE=PHP SRC=xxx I'm not aware of a Content-type such as text/php. What exactly was the purpose of designing yet another inflexible language?! If you want to send PHP source code to the browser, you'd send it as text/plain Other than that, PHP is SERVER-SIDE and sending text/php would be silly, as browsers don't have PHP interpreters (and likely never will). Basically, as far as I can tell, you've waded into PHP pretending that it's C and now are pissed off because it's not C. Well duh! Why not spend a little time to read the [bleep] manual?! http://php.net/manual/ Just focus on the first few sections, up to the point where it starts listing all the extensions and functions. An experienced C programmer could probably read through all that in, what, an hour or two? You would have saved yourself a GREAT DEAL of frustration, and wouldn't have wasted so much time on your rant and the replies. Good Luck! http://php.net/manual/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to make binary strings useful?
actually, ignore that... I didn't read carefuly enough *sighs* M. Sokolewicz wrote: Richard Lynch wrote: Jerry Miller wrote: Is there an example of the UNIX od utility written in PHP? I dunno. Goodle for PHP octal dump Is such a useful task even possible?? Certainly it's possible, though I'm not sure why you wouldn't just USE the existing 'od' utility. 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??? Strings are strings in PHP. They're not bytes thinly disguised as strings by some declarative fiat of the programmer. If you want to convert a string to an integer, then you have to use the http://php.net/ord function to do that. You can then use functions to convert to binary, hex, octal etc. Even the deprecated (why) $str{$inx} notation apparently results in You'd have to read the PHP-Developer list to find out what the rationale for deprecating that feature was. Perhaps the confusion that arose from people thinking strings where arrays, since the syntax for array indexing was the same wasn't worth the benefit of being able to use [] on a string. I have no idea why everyone here believes that syntax is deprecated, since I don't believe it actually is! The deprecated syntax was the one with *square* brackets $string[3] instead of $string{3} etc. another string, because trying to printf it with the %02x format always comes out with 00. (Maybe that's why -- it's useless!) Actually, I've always found [] access to a string quite useful. But since I read the manual, I knew I just got a string which happened to be one character in length from that. As an experienced C programmer, I'm finding PHP to be as counter-intuitive for low-level work as Perl is. So write your utility in C. [shrug] I need to convert binary dumps of data structures into database table rows, and MySQL on my server doesn't support queries from C. Okay, but don't wade into PHP programming pretending that it's C just because the syntax has a surface resemblance to 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 Then your web server PHP CGI configuration is borked. Fix it. yet, the SCRIPT LANGUAGE= SRC= that works perfectly well with JavaScript is likewise ignored if the language is PHP! Finally, Actually, you can use SCRIPT LANGUAGE=PHP on the server to have it parse PHP, but PHP is always parsed on the SERVER, never on the client, so the browser is not going to be able to do much intelligent with SCRIPT LAGNGUAGE=PHP SRC=xxx I'm not aware of a Content-type such as text/php. What exactly was the purpose of designing yet another inflexible language?! If you want to send PHP source code to the browser, you'd send it as text/plain Other than that, PHP is SERVER-SIDE and sending text/php would be silly, as browsers don't have PHP interpreters (and likely never will). Basically, as far as I can tell, you've waded into PHP pretending that it's C and now are pissed off because it's not C. Well duh! Why not spend a little time to read the [bleep] manual?! http://php.net/manual/ Just focus on the first few sections, up to the point where it starts listing all the extensions and functions. An experienced C programmer could probably read through all that in, what, an hour or two? You would have saved yourself a GREAT DEAL of frustration, and wouldn't have wasted so much time on your rant and the replies. Good Luck! http://php.net/manual/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] How to make binary strings useful?
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??? 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!) 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?! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to make binary strings useful?
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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] How to make binary strings useful?
That should help. Thanks. Chris [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php