我正在尝试动态地查看php视图。因此它使用phpwkhtmltopdf打印pdf。
首先,我使用按钮从我的处理程序页面发送查看器页面的名称:
<form action="print.php" method="get">
<button name="printit" type="submit" value="m_dpgmi1.php">print</button>
</form>
然后我在我有phpwkhtmltopdf函数的页面中捕获它:
<?php
require '../vendor/autoload.php';
$template = $_GET['printit'];
use mikehaertl\wkhtmlto\Pdf;
ob_start();
require "'$template'";
$content = ob_get_clean();
// You can pass a filename, a HTML string, an URL or an options array to the constructor
$pdf = new Pdf($content);
$pdf -> setOptions(['orientation' => 'Landscape']);
$pdf->binary = 'C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe';
$pdf->send();
?>
不幸的是我收到了一个错误:
Warning: require('m_dpgmi1.php'): failed to open stream: No such file or directory
它看起来正确require('m_dpgmi1.php')
,除了大括号。有没有办法将变量值作为require参数?