From: RQuadling at GMail dot com Operating system: Irrelevant PHP version: 5.3SVN-2009-11-19 (snap) PHP Bug Type: Feature/Change Request Bug description: A function to eval strings as if they were heredoc'd.
Description: ------------ Hello. I would like to suggest a heredoc() function along the lines of ... string heredoc(string $template, [boolean $suppressErrors [, array &missingVariables]]) The purpose of the the function would be to allow the contents of a string to be interpreted just as if it had been supplied as a variable rather than as a constant. So the output of the example below would be Match. <?php $name = 'Richard'; $template = 'My name is {$name}'; $result = <<< END_RESULT My name is {$name}. END_RESULT; echo $result === heredoc($template) ? 'Match' : 'Different'; ?> Currently, to expand a template, output buffering and/or string/regex search/replace is required. Also eval() COULD be used but that has its own issues. But it would seem all the processing logic already exists in the heredoc functionality. Providing a function based upon the same functionality would certainly make templating easier. The ability to suppress the generation of the errors and to capture the names of missing variables would allow for a degree of flexibility beyond the current implementation of heredoc, but could be worthwhile. Regards, Richard Quadling. -- Edit bug report at http://bugs.php.net/?id=50228&edit=1 -- Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=50228&r=trysnapshot52 Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=50228&r=trysnapshot53 Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=50228&r=trysnapshot60 Fixed in SVN: http://bugs.php.net/fix.php?id=50228&r=fixed Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=50228&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=50228&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=50228&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=50228&r=needscript Try newer version: http://bugs.php.net/fix.php?id=50228&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=50228&r=support Expected behavior: http://bugs.php.net/fix.php?id=50228&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=50228&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=50228&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=50228&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=50228&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=50228&r=dst IIS Stability: http://bugs.php.net/fix.php?id=50228&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=50228&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=50228&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=50228&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=50228&r=mysqlcfg