Posted by Jambalaya on 12/22/06 03:30
> > bill wrote:
[snip]
> > Short, simple question: is there anyway to get php to evaluate a
> > function while in a heredoc block ?
[snip]
> Rik replied:
[snip]
> Possible in heredoc:
> - scalar variables
> - scalar array-values
> - scalar object-values
>
> Not possible in heredoc:
> - functions/results
> - constants
>
> The last is a great irritation.
[snip]
Indeed. But since you can use object values, you can overload a helper
class using the __get overload. So instead of something like:
echo <<<EOT
<input type="checkbox" name="$name"{get_checked_text($id)}>
EOT;
which unfortunately doesn't work, you could do something like:
echo <<<EOT
<input type="checkbox" name="$name"{$checked->$id}>
EOT;
This might be overkill for your needs but it has worked well for me in
the past. Good luck.
J
Navigation:
[Reply to this message]
|