Jump to content

PHP parsing the XMl Declaration


S Murder
 Share

Recommended Posts

When I include a file that holds the xml declaration and doctype, PHP parses the <? and ?> in "<?xml version="1.0" encoding="utf-8"?>". Is there a way to keep PHP from parsing it as code and giving me an error?

Link to comment
Share on other sites

There are a number of ways of doing that. One I would suggest is to simply disable the shorthand(<? ?>), so that PHP only parses <?php ?>. You can do that by insering:

<?php ini_set('short_open_tag',0); ?>

Right before the XML prolog.

Link to comment
Share on other sites

There are a number of ways of doing that. One I would suggest is to simply disable the shorthand(<? ?>), so that PHP only parses <?php ?>. You can do that by insering:
<?php ini_set('short_open_tag',0); ?>

Right before the XML prolog.

If I disable it right in php.ini, I'll have to reset my server, right? I have hosting from GoDaddy. Should I ask them to reset it?
Link to comment
Share on other sites

If I disable it right in php.ini, I'll have to reset my server, right? I have hosting from GoDaddy. Should I ask them to reset it?
You're most probably on a shared server. If they reset it for you, they'll reset it for everybody, and they won't do that. You'll have to disable it yourself with the above method.
Link to comment
Share on other sites

Don't disable anything, don't screw with the configuration. If you do, then everywhere you move your application you'll have to explain to the server admin why they have to do the work because you didn't want to take the time to do it right.In this case, the answer is pretty easy.

<?phpecho "<" . "?xml version=\"1.0\" encoding=\"utf-8\"?" . ">";?>

PHP will not parse the XML tag as PHP.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...