that script in order to make on the fly manipulations to the script, and eventually
save it out. In other words I am using a php script to analyse/edit/create another php
script.
My script seems to be stumbling on the <? and ?> tags. just to test, I am simply trying to
echo out each line of the script to the browser. The <? was not being echo'd at all, though
the ?> was. I made the modification below to simply try and ignore the tags altogether,
but it is still writing out a ?> tag.
Here is my code:
Code: Select all
<?php
$lines = explode("\n", file_get_contents('test.php'));
foreach ($lines as $line)
{
trim($line);
if ($line == "<?") { continue; } // does not appear to work
if ($line == "?>") { continue; } // does not appear to work
print "$line<br>";
}
?>Im assuming the php engine is simply interpreting the opening and closing tags in the string
strangely? How can I circumvent this?