PHP代码里面有回声

I have following code which displays the price in Magento.

<?php echo $this->getPriceHtml($_product); ?>

I have to put this code inside echo instead and I can't get it to work.

I am trying

echo "$this->getPriceHtml ($_product)";

It just displays () on the page.

I tried other combinations and I can't come up with anything else. What am I doing wrong?

Using single quotes will prevent $vars to be interpreted:

echo '$this->getPriceHtml ($_product)';

Or escape the $ sign:

echo "\$this->getPriceHtml (\$_product)";

http://php.net/manual/en/language.types.string.php

Or if by echo-ing you mean that you want to get something like

The price is 123.00

then do:

echo "The price is {$this->getPriceHtml($_product)}";

or even :

echo sprintf("The price is %s", $this->getPriceHtml($_product));

why not you are using this ?

$_product->getFinalPrice() or

if you want in formatted order then why you are not using this number_format($pr->getPrice(), 2)

and if you want price with currency format then you can use this also Mage::helper('core')->currency($pr->getPrice());

Hope it will help you. :)