Welcome Guest, Not a member yet? Register   Sign In
Parsing error when trying to write an RSS feed
#1

[eluser]kenny.katzgrau[/eluser]
Hey guys, awesome framework.

I was making a view file which was essentially a template for an RSS feed.

At the top of the feed template, I had:
Code:
<?xml version="1.0" encoding="utf-8"?>

I found that my server was interpreting the <? ?> in the xml declaration was being picked up by the PHP interpreter, so instead, I wrote:

Code:
<?php echo '<?xml version="1.0" encoding="utf-8"?>'; ?>

But I got parsing errors from my RSS reader because a mysterious semicolon was being placed before all closing ?>, even though it was in the closed string being echo'd.

The put it plainly,

Code:
<?php echo '<?xml version="1.0" encoding="utf-8"?>'; ?>

is produced as:

Code:
<?xml version="1.0" encoding="utf-8"; ?>

Which I think might be a result of CodeIgniter trying to add semi-colons to unterminated statements. I do have the <?= shorttags enabled.

My final solution, although pretty hacky, was to use:

Code:
&lt;?php echo '<' . '?xml version="1.0" encoding="utf-8"?' . '>'; ?&gt;
#2

[eluser]pistolPete[/eluser]
Did you enable "Rewrite PHP Short Tags"? If so, try disabling it.

Code:
$config['rewrite_short_tags'] = TRUE;




Theme © iAndrew 2016 - Forum software by © MyBB