| 
	
 | 
 Posted by M. Sokolewicz on 06/14/84 11:07 
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/ 
>>
 
[Back to original message] 
 |