Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 删除“;“回声”;并将其替换为“;return";?_Php - Fatal编程技术网

Php 删除“;“回声”;并将其替换为“;return";?

Php 删除“;“回声”;并将其替换为“;return";?,php,Php,我有下面的代码,但是,我必须去掉所有的样式(任何css),让它返回而不是回显,否则它会弄乱我正在使用的其他一些代码。 我使用的另一个echo代码是一个短代码,它输出以下内容,这取决于购物车中是否有物品 显然,我不能回音(在回音短代码的结尾),所以我必须返回。如果购物车是空的,它会按照我下面的注释代码返回。当购物车有物品时,我无法让它返回:(我的尝试如下) //Original code, if there's items if(is_object($cart) && $cart

我有下面的代码,但是,我必须去掉所有的样式(任何css),让它返回而不是回显,否则它会弄乱我正在使用的其他一些代码。 我使用的另一个echo代码是一个短代码,它输出以下内容,这取决于购物车中是否有物品

显然,我不能回音(在回音短代码的结尾),所以我必须返回。如果购物车是空的,它会按照我下面的注释代码返回。当购物车有物品时,我无法让它返回:(我的尝试如下)

//Original code, if there's items

if(is_object($cart) && $cart->countItems()) {
  ?>
  <div id="Cart66scCartContents" style="float:right; text-align: right;">
    <a id="Cart66scCartLink" href='<?php echo get_permalink($cartPage->ID) ?>'>
    <span id="Cart66scCartCount"><?php echo $cart->countItems(); ?></span>
    <span id="Cart66scCartCountText"><?php echo $cart->countItems() > 1 ? ' items' : ' item' ?></span> 
    <span id="Cart66scCartCountDash">&ndash;</span>
    <!-- <span id="Cart66scCartPrice"><?php //echo CART66_CURRENCY_SYMBOL . 
      number_format($cart->getSubTotal() - $cart->getDiscountAmount(), 2); ?> -->
    </span></a>
    <a id="Cart66scViewCart" href='<?php echo get_permalink($cartPage->ID) ?>'>View Cart</a>
    <span id="Cart66scLinkSeparator"> | </span>
    <a id="Cart66scCheckout" href='<?php echo get_permalink($checkoutPage->ID) ?>'>Check out</a>
  </div>
  <?php
}
else {

//My code, if there's no items (which works perfectly as a return)

    $emptyMessage = isset( $attrs['empty_msg'] ) ? $attrs['empty_msg'] : 'Your cart is empty';
    return "<p id=\"Cart66scEmptyMessage\" style=\"float:right; text-align: right;\">" . $emptyMessage . "</p>";

}
//原始代码,如果有项目
如果(是对象($cart)&&$cart->countItems()){
?>
| 

您在
$cart->countItems();
处有一个分号,删除该分号,您就可以开始了您在
$cart->countItems();
处有一个分号,删除该分号,您就可以开始了

$html = <<<EOD
        <tr>
          <td>TEST</td>
        </tr>
EOD;
$html=也许

$html=尝试使用

例如:

if (is_object($cart) && $cart->countItems()) {
    $items = $cart->countItems() > 1 ? ' items' : ' item';
    return <<<HTML
<div id="Cart66scCartContents" style="float:right; text-align: right;">
    <a id="Cart66scCartLink" href='{get_permalink($cartPage->ID)}'>
        <span id="Cart66scCartCount">{$cart->countItems()}</span>
        <span id="Cart66scCartCountText">{$items}</span>
        <span id="Cart66scCartCountDash">&ndash;</span>
        </span></a>
    <a id="Cart66scViewCart" href='{get_permalink($cartPage->ID)}'>View Cart</a>
    <span id="Cart66scLinkSeparator"> | </span>
    <a id="Cart66scCheckout" href='{get_permalink($checkoutPage->ID)}'>Check out</a>
</div>
HTML;
}
else {
    $emptyMessage = isset( $attrs['empty_msg'] ) ? $attrs['empty_msg'] : 'Your cart is empty';
    return "<p id=\"Cart66scEmptyMessage\" style=\"float:right; text-align: right;\">" . $emptyMessage . "</p>";

}
if(is_object($cart)&&$cart->countItems()){
$items=$cart->countItems()>1?'items':'item';
return尝试使用

例如:

if (is_object($cart) && $cart->countItems()) {
    $items = $cart->countItems() > 1 ? ' items' : ' item';
    return <<<HTML
<div id="Cart66scCartContents" style="float:right; text-align: right;">
    <a id="Cart66scCartLink" href='{get_permalink($cartPage->ID)}'>
        <span id="Cart66scCartCount">{$cart->countItems()}</span>
        <span id="Cart66scCartCountText">{$items}</span>
        <span id="Cart66scCartCountDash">&ndash;</span>
        </span></a>
    <a id="Cart66scViewCart" href='{get_permalink($cartPage->ID)}'>View Cart</a>
    <span id="Cart66scLinkSeparator"> | </span>
    <a id="Cart66scCheckout" href='{get_permalink($checkoutPage->ID)}'>Check out</a>
</div>
HTML;
}
else {
    $emptyMessage = isset( $attrs['empty_msg'] ) ? $attrs['empty_msg'] : 'Your cart is empty';
    return "<p id=\"Cart66scEmptyMessage\" style=\"float:right; text-align: right;\">" . $emptyMessage . "</p>";

}
if(is_object($cart)&&$cart->countItems()){
$items=$cart->countItems()>1?'items':'item';

return声明字符串变量,并连接您试图在该字符串中回显的所有HTML,然后返回字符串变量

示例$string=
声明字符串变量并连接您试图在该字符串中回显的所有HTML,然后返回字符串变量

示例$string=
@andreas:谢谢-解析错误:语法错误,意外“.”在/home/…在线1@andreas:在
$cart->getDiscountAmount(),2)
-所有问题都解决了!谢谢:)显然你还需要找到其余的;),我只是在给指针谢谢:)现在购物车项目也不显示了:(
$cart->countItems().
现在为空。可能最好开始一个新问题,并将代码粘贴到新问题上的countItems()函数:)@andreas:Thank you-Parse error:syntax error,意外“.”in/home/…on line1@andreas:在
$cart->getDiscountAmount()处还有一个分号,2)
-全部修复!谢谢:)显然你还需要找到其余的;),我只是在给指针谢谢:)现在购物车项目也不显示了:(
$cart->countItems()。
现在为空,最好开始一个新问题,并将代码粘贴到countItems()函数上新问题:)