RE: Asking for the impossible?
| From: | Peter Kocks | Date: | Fri, 24 Mar 2000 15:59:59 +0000 |
| Subject: | RE: Asking for the impossible? | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-12576@lists.php.net to get a copy of this message | ||
>
> Try
>
> $s = $cart->show();
> $c = $cart->count;
>
> // A here doc
> print <<< END
> <HTML>
> Status: $s
> Count: $c
> </HTML>
> END;
>
Yes, this will work, but it does not allow for the calling
the method within the string. I tried to keep the example
simple, but there is a next step that makes this technique
powerful.
Consider,
// A here doc
print <<< END
<HTML>
Status: {$cart->show()}
Count: {$cart->count}
<TABLE>
Contents:<p>
{$cart->table("<TR>", "</TR>", "<TD>",
"</TD>")}
</HTML>
END;
The table() method would take four arguments, a pre-string
and post-string for rows and cells of the table.
The ultimate objective being to create a framework where
here docs contain all of the relevant HTML code and the php
class contains all of the php logic. I think a system would
be nice because it would be easier to do all of the HTML
formatting in one place.
--pk