Endianness in PHP

[email protected] ("J. Adams")
Newsgroups php.pecl.dev
Message-ID <[email protected]>
Two questions:
1) Is there a standardized way or recommended best practice for 
conversions of ints, longs, and doubles to network byte order?
2) Can anyone recommend a cheap way to gain access to a Big-Endian 
machine for development and testing?


The reason I ask is that I see that AMFEXT makes no effort to convert 
byte order when serializing an integer:
http://lxr.php.net/xref/PECL/amfext/amf.c#amf3_write_int

The AMF3 spec indicates that numbers are to be serialized in network 
byte order (i.e., "big-endian"). I see that Z_LVAL macros are used to 
extract the actual number data from a zval object or pointer to zval 
object by grabbing the contents of the zval's "lval" field  which is 
declared as long. That function I linked, amf3_write_int, appears to 
work fine on a linux box with intel chip.  I'm thinking it would break 
on a big-endian chip.

Any advice would be greatly appreciated!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.