1
請我需要更換條碼模板PDF,寫條形碼
代碼:
$tmp_product = str_replace("{::prod_price}", $product['price'], $tmp_product);
$eancodes = $product['ean'];
$eancode = new TCPDFBarcode($eancodes, 'EAN13');
$tmp_product = str_replace("{::prod_ean}", $eancode, $tmp_product);
HTML模板:
define('PDF_TEMPLATE_PROD', '
<tr class="pdf_prod" id="{::prod_name}" nobr="true">
<td class="pdf_prod_desc">
<ul class="pdf_prod_ul">
<li><strong>{::txt_prod_price}</strong> {::prod_price}</li>
<li class="pdf_prod_bcode">{::prod_ean}</li>
</ul>
</td>
</tr>
');
它看起來像所有你需要的是$ tmp_product設置爲'PDF_TEMPLATE_PROD的價值'在替換代碼之前。當你在第一個str_replace之前添加這個時會發生什麼:'$ tmp_product = constant('PDF_TEMPLATE_PROD');'? – Stiliyan
它沒有區別,仍然是一個問題 – Patcino
究竟是什麼問題?你看到了什麼輸出? – Stiliyan