Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to use PHP inside XML. I create some XML file and everything is OK on my local WAMP server. But online (on ipage server) just problem. I include

AddHandler application/x-httpd-php .xml

in .htaccess file. I saw server can't see something like

<src lang='en'><?php echo "files/en/strana1.jpg"; ?></src>

This is part of XML file. But this cod work perfekt in localhost WAMP server. How to echo/print some text with PHP inside XML??? Maybe problem is in server configuration or ...

share|improve this question
Do you get any errors? Or is the PHP code simply not being processed? – w3dk Aug 6 '14 at 22:05

Make sure that short tags are disabled in your production environment as <? is used by PHP and XML and will conflict when you use the two together. WAMP has short tags disabled by default but most web hosts do not to ensure greater compatibility with older PHP scripts.

Since the odds are you won't be able to change the php.ini file of your host you can try to change this in your htaccess file by placing the following line in it:

php_value short_open_tag 0
share|improve this answer
When I do that i receive 500 Internal Server Error. – user3626223 Aug 6 '14 at 21:14
AFAIK this is only really a problem with the XML prolog eg. <?xml version="1.0"?>. If your XML files are being processed by PHP and you have short open tags enabled then the XML prolog gets processed as PHP and you end up with a fatal parse error. Other PHP blocks in the XML file would simply get processed as PHP (before the XML is processed). The workaround here is to echo the XML prolog, eg. <?php echo '<?xml version="1.0"?>'; ?>. – w3dk Aug 6 '14 at 22:21
Yeee man that is it... Thanks a lot... – user3626223 Aug 7 '14 at 18:49

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.