2014-03-06 77 views
0

我目前有一個奇怪的(對我來說)與PHP的問題。我與DOMPDF工作,從而分配輸出HTML到$輸出變量,如下所示:回聲不工作變量內

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相關的問題 - 但我太多新手瞭解我一直在做錯什麼,所以任何幫助將不勝感激。

親切的問候
奧利

回答

3

如果你是在談論這一行

$output .='<table id="contact">Some more HTML and text'. echo $test .'</h1> 
<div id="content">' . 

你不需要做呼應您可以連接如

$output .='<table id="contact">Some more HTML and text'. $test .'</h1> 
<div id="content">' . 
+0

「你可以連接」可能是不是足夠強大,因爲PHP拋出一個錯誤,並停止執行,否則(這是他看到的行爲)。 – Mordred