Wanted: PHP core function for dynamically performing double-quoted string variable interpolation

For a long time I’ve wished PHP had a built-in function for dynamically evaluating a string variable as a double-quoted string or HEREDOC, to perform variable interpolation (aka expansion) on-the-fly. It’s frequently useful to store a template in a string and then interpolate data into it later, pass the template to a function, etc. Example:

Continue reading