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

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:
<?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:

<?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,

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

is produced as:

<?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:

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

Did you enable "Rewrite PHP Short Tags"? If so, try disabling it.

$config['rewrite_short_tags'] = TRUE;

Theme © iAndrew 2016 - Forum software by © MyBB