Page 1 of 1

php include in html $output

Posted: Mon Dec 07, 2009 11:56 am
by mrlayance
I can not figure this out. When the page in generate the <php ?> are translated a html....

Code: Select all

<?php
// set source file name and path
$source = "flowsum.txt";
 
// read raw text as array
$raw = file($source) or die("Cannot read file");
 
// retrieve first and second lines (title and author)
$slug = array_shift($raw);
$byline = array_shift($raw);
 
// join remaining data into string
$data = join('', $raw);
 
// replace special characters with HTML entities
// replace line breaks with <br />
 
$html = nl2br(htmlspecialchars($data));
 
// replace multiple spaces with single spaces
//$html = preg_replace('/\s\s+/', ' ', $html);
 
// replace URLs with <a href...> elements
$html = preg_replace('/\s(\w+:\/\/)(\S+)/', ' <a href="\\1\\2" target="_blank">\\1\\2</a>', $html);
 
//space to space
$html = str_replace(' ', '&nbsp;', $html); 
 
 
// start building output page
// add page header
$output =<<< HEADER
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Netflow</title>
<style>
@import url("dashboard/style.css");
 
.slug {font-size: 12pt; font-weight: bold}
.byline { font-style: italic }
</style>
</head>
 
<body>
 
$output .= "<?php include ('/htdocs/dashboard/search/highlight/timer.php') ?>";
$output .= "<?php include ('/htdocs/dashboard/search/highlight/sehl-1.8.3.php') ?>";
$output .= "<?php include ('/htdocs/dashboard/search/highlight/sehl') ?>";
$output .= "<?php include ob_start ?>";
 
HEADER;
 
// add page content
$output .= "<div class='slug'>$slug</div>";
$output .= "<div class='byline'>$byline</div>";
$output .= "<pre><div>$html</div></pre>";
 
// add page footer
$output .=<<< FOOTER
</body>
$output .= "<?php include ('ob_end_flush')"; 
</html>
FOOTER;
 
// display in browser
echo $output;

Re: php include in html $output

Posted: Mon Dec 07, 2009 12:03 pm
by AbraCadaver
You're going to have other problems, but for the one you're asking about, try moving line 52 to 46.

-Shawn