On Sun, 2005-10-30 at 21:24 -0500, John Taylor-Johnston wrote: > <?php > > >>$contents = "<div class=\"indent\" style=\"font-size: 16px; font-family: > >>arial,helvetica; font-weight: bold;\">About the Project</div> > >><?php echo \"hello world\"; ?>"; > >>echo eval($contents); > >>?> > >>eval() expects PHP code, not HTML with embedded PHP code. Try this > >>(untested): > >> > >>eval( " ?> $contents <?php " ); > >> > Scary. But it works. > Shouldn't that error because of the unexpected ?> and <?php in a bigger > example?
No, because eval(), when passed string $str, effectively does this silently: $str = "<?php " . $str . " ?>"; and then passes $str to the PHP interpreter. Which is, in most cases, what you want, because you want to evaluate PHP code. However, if eval() is the answer, you're probably asking the wrong question. You should take a hard look at your code and think of a better way to do what you need to do. I can assure you one does exist, but with your example it's fairly obvious, so you'd need to explain better what you're trying to do before I could help you. -- Jasper Bryant-Greene General Manager Album Limited e: [EMAIL PROTECTED] w: http://www.album.co.nz/ b: http://jbg.name/ p: 0800 4 ALBUM (0800 425 286) or +64 21 232 3303 a: PO Box 579, Christchurch 8015, New Zealand -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php