【发布时间】:2014-04-09 17:56:17
【问题描述】:
我目前在使用 PHP 时遇到了一个奇怪的(嗯,对我而言)问题。我正在使用 dompdf,因此将输出 HTML 分配给 $output 变量,如下所示:
function ppt_pdf_output() {
// post-ID of referring page needed
$post = get_post($_POST['postid']);
$category = get_the_category($_POST['postid']);
$test = 'Test!';
$output = '<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>'.$post->post_title.'</title>
<style>
@page {
margin: 200px 50px 80px 50px;
}
/* more styles */
</style>
</head>
<body>Some content and HTML';
$output .='<table id="contact">Some more HTML and text'. echo $test .'</h1>
<div id="content">' .
apply_filters('the_content',$post->post_content) . '</div>';
$output .= '</body></html>';
return $output;
}
我没有得到什么:Wordpress 变量在生成的 PDF 中显示得很好,但是只要我想回显一个自定义变量(如本例中的 $test),我就会得到一个空白页(不是空白PDF,但我什至无法生成它)。
我认为这实际上不是与 dompdf 相关的问题,而是与 PHP 相关的问题 - 但我太新手了,无法弄清楚我做错了什么,因此非常感谢任何帮助。
亲切的问候
奥利
【问题讨论】: