簡體   English   中英

如何正確地將此PHP echo語句與字符串和函數連接在一起?

[英]How do I properly concatenate this PHP echo statement with a string and a function?

//top of the code just consists of an if statement and some code.
case 'itemimage' :

        echo '<div class="product-preview-image" style="background: red; height:75px; width:75px;"><img href=' . <?php grab_item_image(); ?> . "</div>"';
break;
    }
}

那是我的嘗試,但在我的文本編輯器上看起來並不禮貌。 我也使用inline-css不確定是否重要。

我要回聲的唯一一件事是該div具有提供href的功能。

<div class="product-preview-image" style="background: red; height:75px; width:75px;"><img href="#thephpfunctionhere"</div>

這使我對所有單引號和雙引號感到困惑。

報價問題,您再次啟動<?php 使用下面的代碼

//top of the code just consists of an if statement and some code.
case 'itemimage' :

        echo '<div class="product-preview-image" style="background: red; height:75px; width:75px;"><img src="' .  grab_item_image() . '" /></div>"';
break;
    }
}

希望這對您有幫助

echo '<div class="product-preview-image" style="background: red; height:75px; width:75px;"><img src="' . <?php grab_item_image(); ?> . '"></div>"';

圖片需要“ SRC”屬性,而不是href。 另外,由於您在php標簽內回顯,因此不必再次打開<\\?php,而是直接引用該函數。

echo 
    '<div class="product-preview-image" style="background: red; height:75px; width:75px;">' ,
        '<img src="' .  grab_item_image() . '" />' ,
    '</div>"';

使用直接回聲時,Komma的速度甚至更快。 不適合將其分配給$ variable

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM