I have a flash element (I know, but please don't) with a settings.xml file.
One of the values in the XML file depends on the URL, so rather than having multiple instances of the flash folder, I want to do the following:
value="<?php $rest = substr(<?php echo curPageURL(); ?>, -2, -1) ?>"
I tried that in vain, but as you probably already knew, that won't work.
So I either need a way to write that in XML, or to allow that line of PHP within the XML file.
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {
$pageURL. = "s";
}
$pageURL. = "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL. = $ _SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL. = $ _SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
You need two things for this to work:
Your server would need to be configured to parse XML files as PHP files. If you're using Apache, that's something in your configuration similar to this:
You'd need to use valid PHP syntax, like so:
Assuming that
curPageURL()
is a function defined in PHP.Finally, you should ensure that the
short_open_tag
directive is set toOff
in yourphp.ini
configuration, or else PHP will throw syntax errors when it encounters XML opening tags, e.g.<?xml
. This can be done in .htaccess with something similar to