Ready for XForms

PHP Logo

I just felt on a page dedicated to XForms on It’s pretty much only information as nothing special is required, but the method is still interesting. Since XForms sends the data as XML as the POST data for the HTTP request (as raw data). If always_populate_raw_post_data is set to on (which is not a default setting), the data can be accessed from $_SERVER['HTTP_RAW_POST_DATA']. Using this setting will cause PHP to always populate a variable with data that could be large, which would cause slow downs with time. Instead, you can read the data from the input stream when required. Once you have the raw data, you can simply use your XML parser of choice to read the content.

 <?php $fp = fopen( "php://stdin", "r" ); $data = ''; while( !feof( $fp ) )    $data .= fgets( $fp ); fclose( $fp ); ?> 

Even if XForms is not currently supported in browsers, it’s already used by multiple applications and should soon become an important standard in application communication. Of course, the traditional URL encoded POST data does the job, but XML simply opens more possibilities, such as validation against an XML Schema. It’s also a lot easyer to implement for a common application. All languages have XML libraries ready to use.

As a side note, I also noticed a section on security which gathers the most important concepts to be aware of during development. It seems like a response to multiple articles on security that have been written recently. Having all those informations centralized can’t be a bad thing.

Leave a Reply

Your email address will not be published. Required fields are marked *