Object.prototype.toPHP = function () {
        var retf='O:8:"stdClass":';
        var reta=':{';
        var ct=0;
        var last;
        for (var i in this) {
                if (typeof this[i] == 'function') continue;
                reta+=i.toPHP()+this[i].toPHP();
                ct++;
        }
        return retf+ct+reta+'}';
}
String.prototype.toPHP = function () {
/*
Make sure all strings have network-style carraige
returns; if we don't, PHP doesn't recognize the
length as correct. As a result, the String type
is not binary safe. What are you doing passing
binaries via POST anyway?? Use the normal file
uploading for cripes sake.
*/

        var s=this.replace(/((?:\r|\n|\r\n))/g,'\r\n');
        var i=-1,ct=0;
        while ((i=s.indexOf('\n',i+1))!=-1) ct++;
        return 's:'+(s.length-ct)+':"'+s+'";';
}
Boolean.prototype.toPHP = function () {
        return 'b:'+(this==true?1:0)+';';
}
Number.prototype.toPHP = function () {
        /* Only make it a double if we actually need to */
        return (this==Math.floor(this)?'i':'d')+':'+this.toString()+';';
}
Date.prototype.toPHP = function () {
        /* Changes into an int compatible with mktime() */
        return 'i:'+Math.floor(this.getTime()/1000)+';';
}
Array.prototype.toPHP = function () {
        var ret='a:'+this.length+':{';
        for (var i=0; i<this.length; i++)
                ret+=i.toPHP()+this[i].toPHP();
        return ret+'}';
}
Function.prototype.toPHP = function () {
        return null;
}