You are here: Re: Getting a function result while in heredoc « PHP Programming Language « IT news, forums, messages
Re: Getting a function result while in heredoc

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация