RE: Asking for the impossible?
| From: | Mark Nold | Date: | Fri, 24 Mar 2000 10:44:59 +0000 |
| Subject: | RE: Asking for the impossible? | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-12556@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;
Personally i've never used here docs in PHP but i always found that in Perl due to my nice
indenting the HTML output looked horrible.
mn
On Friday, 24 March 2000 11:45, Peter Kocks [SMTP:peter.kocks@baygate.com] wrote:
> Hello list,
>
> I'm looking for a way to call a class method within a string. Example,
>
> class Cart {
> var $count;
>
> function show(){
> $str = "I'm an empty cart<p>";
> $this->count++;
> return $str;
> }
> }
>
> $cart = new Cart;
>
> // A here doc
> print <<< END
> <HTML>
> Status: $cart->show()
> Count: $cart->count
> </HTML>
> END;
>
> I' like the output to be:
>
> Status: I'm an empty cart
> Count: 1
>
> However, the $cart->show() is embedded in a string, or in this case a here
> doc, and so I get the output:
>
> Status:
> Count: 1
>
> Any ideas?
>
> --pk
>
>
>