【发布时间】:2013-09-16 09:59:36
【问题描述】:
我有这个代码:
echo '<form method="post" class="product" action="index.php" id="addtocartproduct<?php echo $products->virtuemart_product_id ?>">';
我必须在 echo 中使用 echo,而且我必须永远不要在这一行中使用 php。 我怎么能编辑这一行,使它像:
echo '<form method="post" class="product" action="index.php" id="addtocartproduct echo $products->virtuemart_product_id ">';
编辑: 感谢每一位非常有用的帮助。 现在我有另一个问题。我可以用这条线做什么:
echo'<input type="hidden" class="pname" value="<?php echo $product->product_name ?>">';
【问题讨论】:
-
echo "<form method='post' class='product' action=index.php id='addtocartproduct $products->virtuemart_product_id'>";变量被插在双引号中,你不需要另一个回显。但更好的解决方案是不回显整个 HTML。即://.. some PHP there ... then closing the tag; ?> <form action="index.php .... id="addtocartproduct <?=$products->virtuemart_product_id;?>">
标签: php