AMFPHP maps data types from PHP to AS and vice versa naturally. The following tables outlines the corresponding types in PHP and AS.

AS type PHP type Notes Automatic
null null Yes
boolean boolean Yes
String string Yes
Date float UNIX timestamp, set return type to date to send to AS. See also DateWrapper class No
Array array Yes
Object associative array * Yes
XML string Set return type to xml to send to AS No
Recordset Resource PHP to actionscript only Yes

For automatic types, there is no need to explicitely set the return type for your service method in the methodTable. However, in the case of manual types, you should set the return type, as shown in the following example:


class RemoteDate
    function RemoteDate()
        $this->methodTable = array( 
            "getRemoteDate" => array(
                "description" => "returns the local time on the 
server as flash Date Object",
                "access" => "remote",
                "returns" => "Date"
            "getRemoteDateString" => array(
                "description" => 'returns the local time on the 
server as String formated like "Sun Mar 12 00:06:30 GMT+0800 2006"',
                "access" => "remote",
            "getTimezoneOffset" => array(
                "description" => "returns the difference, in minutes,
 between the servers's local time and universal time",
                "access" => "remote",
    function getRemoteDate()
        //Note:: you must return the number of milliseconds, hence the 
        return time()*1000;
    function getRemoteDateString()
        return date('D M d H:i:s \G\M\TO Y', time());
    function getTimezoneOffset()
        return date('Z')/60;

Seasoned Flash developers should note that PHP booleans are converted to strings as follows: true -> "1", false -> "". This can cause some confusion when inserting Flash booleans into a database; a simple workaround is $bool ? "true" : "false".

Some have asked why we didn’t use stdClass as a mapping to Object. It is a design decision leftover from the very beginnings of AMFPHP. The rationale is that associative arrays have much more functions to work with and they are more natural in PHP, while stdClass objects are basically useless. If it really bothers you, you can map arguments to specific classes by setting the appropriate type in the arguments of the methodTable array. | Disclaimer | Conditions of use