4 Replies Latest reply on Mar 3, 2011 5:34 PM by M3r3mortal

    Flex and PHP

      I'm not a big fan of XML and when dealing with data between Flex and PHP I prefer sending the raw variables rather than encoding them in XML, sending them and then decoding them. I just don't get the reason why I should loose precious time by encoding/decoding XML. This being said let's go on:
      1. I send some variables to PHP with a URLRequest/URLLoader/URLVariable in the form: file.php?var1=value1&var2=value2
      2. If value1 is a html-text it gets html encoded and special chars (like &) are converted to & You can see the problem: My new request becomes: file.php?var1=sometext&othertext&var2=value2
      3. the same thing when loading variables from a PHP file - Flex even throws a error because variables and values must be in pair.

      As an extra: every output from any PHP file contains a starting space character that could lead to some problems in certain cases.

      If anyone has any idea I would greatly appreciate it.

      - this has nothing to do with urlencode function in php
      - now I use a custom RegExp function to correct this
        • 1. Re: Flex and PHP
          chris.huston.t10 Level 3
          Have you tried using HTTPService to transfer data between Flex and PHP? I find it easier than URLVariable and you can solve the html-text problem by using POST with this. Another option could be to use AMFPHP or WebORB for PHP to transfer data. Both use remoting which is very efficient and handle all the data serialization for you.

          • 2. Re: Flex and PHP
            I would definatly look into AMFPHP. works great with flex
            • 3. Re: Flex and PHP
              sowmya shivakumar

              u can convert the array in to a string in FLEX and in PHP u can use the "split" command...

              here s sample program see if it helps u



              similary u can transfer VARIABLES also,in the place of the string just put ur variable on the PHP use t variable without spliting t

              • 4. Re: Flex and PHP

                as said above you should take a look at AMF, although I use Zend AMF

                forget name/value pairs or xml nonsense. Just pass arrays of objects as arraycollections


                you call PHP methods as easily as you would methods in an actionscript class.


                I only recently started using AMF and I'm well impressed on how straightforward it is. It also sends using binary data and with no xml overheads it makes it faster and less bandwidth. Especially useful for mobile apps