0
我在將HTML轉換爲PDF時出現問題(使用Dompdf)0.8.0,我一直在尋找答案。我發現我需要將DOMPDF_ENABLE_PHP
更改爲true
。我的問題是我不知道在哪裏改變或如何改變。如何更改DOMPDF_ENABLE_PHP
對不起,如果這是一個愚蠢的問題;我仍然是一名新秀。
這裏是我的PHP代碼
<?php
require __DIR__."/../vendor/autoload.php";
use Dompdf\Dompdf;
//generate some PDFs!
$dompdf = new DOMPDF(); //if you use namespaces you may use new \DOMPDF()
$dompdf->loadHtml(file_get_contents("re1.php"));
$dompdf->render();
$dompdf->stream("sample.pdf", array("Attachment"=>0));
?>
我re1.php
<?php require '../db.php';?>
<!DOCTYPE html>
<html>
<head>
<title></title>
<?php include '../templates/links.inc';?>
</head>
<body>
<div class="container">
<?php
$countr=0;
$sline = explode(",", $_SESSION["hroomid"]);
foreach ($sline as $id) {
$result = $mysqli->query("SELECT r.*,rt.* FROM tbl_room r INNER JOIN
tbl_roomtype rt ON r.`RoomTypeID` = rt.`RoomTypeID` WHERE RoomID =
'$sline[$countr]'");
$row = $result->fetch_assoc();
echo $row['RoomNumber'];
$countr++;
}
?>
</div>
</body>
</html>
上的PDF輸出:
query("SELECT r.*,rt.* FROM tbl_room r INNER JOIN tbl_roomtype rt ON
r.`RoomTypeID` =
rt.`RoomTypeID` WHERE RoomID = '$sline[$countr]'"); $row = $result-
>fetch_assoc(); echo
$row['RoomNumber']; $countr++; } ?>
非常感謝先生...... –