views:

68

answers:

1

I tried this as a test:

<?php
$crap = "<![CDATA[Hello, world!]]>";
$crap = str_replace(list("<![CDATA[", "]]>"), "", $crap);
echo $crap;
?>

But it returned this:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ')' in /srv/www/htdocs/test.php on line 3
+4  A: 

Replace list with array. list is used for making several variable attributions at the same time.

But you should not parse XML with str_replace. Consider the following valid file:

<?xml version="1.0" ?>
<root>
<![CDATA[&]]>
</root>

After your replacement, it becomes:

<?xml version="1.0" ?>
<root>
&
</root>

which is invalid XML.

Artefacto