The PHP AMF3 extension provides two functions:
Returns a binary string containing an AMF3 representation of $value
. On error, returns FALSE
and issues a warning message. The $opts
argument is a bitmask of the following bit constants:
AMF3_FORCE_OBJECT
: force encoding non-indexed arrays as anonymous objects;
Returns the value encoded in $data
. Optional $pos
marks where to start reading in $data
(default is 0). Upon return, it contains the index of the first unread byte (-1 indicates an error).
The $opts
argument is a bitmask of the following bit constants:
AMF3_CLASS_MAP
: enable class mapping mode (see the usage constrains below);AMF3_CLASS_AUTOLOAD
: enable the PHP class autoloading mechanism in class mapping mode;AMF3_CLASS_CONSTRUCT
: call the default constructor for every new object in class mapping mode;
To install the extension, type the following in the source directory:
phpize
./configure
make
make install
This should install the extension in your default PHP extension directory. If it doesn't work as
expected, manually put the target amf3.so
library where the extension_dir
variable in your
php.ini
points to. Add the following line to the corresponding section in your php.ini
:
extension=amf3.so
To run tests, type:
make test
- PHP
NULL
,boolean
,integer
,float
(double),string
,array
, andobject
values are fully convertible to/from their corresponding AMF3 types; - AMF3
Date
becomes a float value whereasXML
,XMLDocument
, andByteArray
become strings; - In a special case, PHP integers are converted to AMF3 doubles according to the specification.
- A PHP
array
is encoded as an indexed array when it has purely integer keys that start from zero and have no gaps. An empty array adheres to this rule. In all other cases, an array is encoded as as associative array to avoid ambiguity. - When class mapping is disabled (the default), AMF3 objects are returned as associative PHP arrays. Otherwise, they are returned as PHP objects.