I'm currently having an odd (well, for me) problem with PHP. I'm working with dompdf and thus assigning the output HTML to a $output variable as follows:
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;
}
What I don't get: The Wordpress variables show up just fine in the generated PDF, but as soon as I want to echo a custom variable (like $test in this example) I just get a blank page (not a blank PDF, but I'm not even able to generate it).
I assume it's not really a dompdf-related issue, but a PHP-related - but I'm too much of a novice to figure out what I've been doing wrong, so any help would be greatly appreciated.
Kind regards
Olli
If you are talking about this line
$output .='<table id="contact">Some more HTML and text'. echo $test .'</h1>
<div id="content">' .
you do not need to do echo you can concatenate as
$output .='<table id="contact">Some more HTML and text'. $test .'</h1>
<div id="content">' .