Setting up your FSDL document for PHP

I’m not much of a coder, but when in a bind I can do a few simple things with languages like JavaScript and PHP. When I started testing my first Frogans slide with PHP code, I ran into a few glitches, so I thought I’d share the solutions here.

As FSDL is written in XML, you can build dynamic Frogans sites using any HTTP server scripting language, like PHP, for instance. PHP is free to use and it’s extremely popular. So it’s a good choice for setting up your first dynamic Frogans site.

An FSDL file that uses PHP is no different than an ordinary FSDL file, except that:

  1. The file is named with the extension  “.php” instead of “.fsdl”;
  2. It is hosted on an HTTP server, and not on a local disk (unless your computer is running an HTTP server); and
  3. It contains the requisite PHP code that the server will interpret when serving the document to Frogans Player.

If you’ve already created HTML pages in PHP, this will appear pretty obvious. But with HTML pages, the server will probably serve your page correctly even if you forget to include requisite PHP code in the document. Your server might be less forgiving if you forget to do so with FSDL (written in XML).

First off, you’ll need for your document to start with a line of PHP code that tells the server that this is an XML document:

<?php
header("Content-type: text/xml");
?>

This way, the server should send to Frogans Player your document containing all of the FSDL code written below that line. But my experience was that Frogans Player for Developers (alpha.018.1) returned an error message that the XML declaration, normally the first line of your FSDL document, could not be found.

The solution is to “echo” the XML declaration in your PHP code, for example:

<?php
header("Content-type: text/xml");
echo "<?xml version='1.0' encoding='utf-8'?>";
?>

I don’t know why it is necessary to echo the XML declaration in PHP, rather than just including it in your regular FSDL code – and it may or may not be necessary to do so in future implementations of Frogans Player – but if you’re having trouble getting Frogans Player to parse your PHP document, this might be the fix you’re looking for.


Udpate: An even simpler method exists. Simply start off your PHP document with this:

<?php
print("<?xml version='1.0' encoding='utf-8'?>");
?>

Be the first to comment

Leave a Reply

Your email address will not be published.


*