PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
I have set up two pages, content.php and template.php, I was the content.php file to contain a variable that will contain all the html for my content that will then be displayed within my template.php file, mostly this works fine. However the problem I have is that I want additional html in my content.php file so that when other people are editing it looks more like the finished file. My problem is that when I add this additional html it is being passed into the template.php file even though it is not within the content variable. Hopefully this code snippet will explain it:
<html><head>head><body
<table width="100%" cellpadding="10" cellspacing="0"><tr><td width="30%" valign="top" bgcolor="#EEEEEE">
Beach Hostel is located right next to one of Holland’s beautiful beaches. There’s nothing that can beat the sound of waves and the tranquility of the beach-life, especially after you’ve been surrounded by the madness of the city (of Amsterdam) for a while. This Flying Pig Hostel is known for offering you the best chill out spot you can imagine; in this backpacker hostel you can relax, smoke, hang out with friends, party or challenge your limits and abilities in various beach sports!
</td>
<td width="70%" valign="top">
<?php echo $content; ?>
</td></tr></table>
</body></html>
<p>TEST CONTENT - this is displayed even though it is outside the php tags?</p>
<?php ob_start(); ?>
<p>The Beach Hostel is located right next to one of Holland’s beautiful beaches. There’s nothing that can beat the sound of waves and the tranquility of the beach-life, especially after you’ve been surrounded by the madness of the city (of Amsterdam) for a while. This Flying Pig Hostel is known for offering you the best chill out spot you can imagine; in this backpacker hostel you can relax, smoke, hang out with friends, party or challenge your limits and abilities in various beach sports!</p>
<?php
//Assign all Page Specific variables
$content = ob_get_contents();
ob_end_clean();
//Apply the template
include("template.php");
?>
Why is the <p>Test..... part being passed accross and displayed in the template file?
Okay I see what you mean now, is there anyway around this, at the moment it means that when the content page is edited the layout bears no resemblance to how it looks when contained within the final template page.
<?
if(isset($_REQUEST['test']) && $_REQUEST['test']==1)
{
echo'<p>TEST CONTENT - this is displayed even though it is outside the php tags?</p>';
echo'<p>The Beach Hostel is located right next to one of Holland’s beautiful beaches. There’s nothing that can beat the sound of waves and the tranquility of the beach-life, especially after you’ve been surrounded by the madness of the city (of Amsterdam) for a while. This Flying Pig Hostel is known for offering you the best chill out spot you can imagine; in this backpacker hostel you can relax, smoke, hang out with friends, party or challenge your limits and abilities in various beach sports!</p>';
}
else
{
ob_start();
//Assign all Page Specific variables
$content = ob_get_contents();
ob_end_clean();
//Apply the template
include("template.php");
}
?>
Its is clever how that works, but what I need is a way that the formatting can be shown in dreamweaver without any code running (for editing the content.php page), but then when the content.php is run and is within the template.php it not displaying the extra formatting code/text.