Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XML Making PHP Unexpected String Error [closed]

Tags:

php

parsing

xml

I am getting this error

Parse error: syntax error, unexpected T_STRING in /ho.../ssd/recording-goodbye.php on line 1

I have found that this line is causing this:

<?xml version="1.0" encoding="UTF-8"?> 

I think this is because short tags are enabled on this server, it's a shared hosting account and I don't have access to the php.ini file. Is there a way I can perhaps set the headers or escape this line?

This is the full content of recording-goodbye.php

<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
<Response>
    <Say>Thanks for your recording.  Here is what I heard</Say>
    <Play><?php echo $_REQUEST['RecordingUrl']; ?></Play>
    <Say>Goodbye</Say>
</Response>
like image 888
Doug Molineux Avatar asked Feb 04 '26 14:02

Doug Molineux


2 Answers

This fixed it

<?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
like image 53
Doug Molineux Avatar answered Feb 07 '26 03:02

Doug Molineux


Try the technique described here: http://www.bin-co.com/php/articles/using_php_short_tags.php

It involves treating your xml file so that when it's interpreted by a php configuration using short tags, it will still come through as XML.

like image 29
Jonathan M Avatar answered Feb 07 '26 02:02

Jonathan M



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!