Newbie - Quotes in HTML problem
Posted: Mon May 29, 2006 11:53 am
Hi guys, I'm sorry if this is really obvious. I've fairly recently started learning PHP, I'm reading the book "PHP and MySQL Web Development" by Welling and Thomson, and I'm trying to implement one of their examples to get some practice. It's basically a PHP template for easily adding pages to a web site so the structure remains the same, but the main content can be easily changed. A web page would, for example, contain this:
the "page.inc" file contains:
Everything works, apart from that the single quotes in the HTML that makes up the content are replaced by three strange characters when the page is loaded in a browser. If that makes sense.
I know some of the code may seem a bit basic or badly written, but I'm new!
Can anyone help me out?
Thanks
Henry
Code: Select all
<?php
require('page.inc');
$homepage = new Page();
$homepage->content = " <h3>Vic Demone’s music and live shows are an explosive celebration of melodies, beats and stories.
</h3>
<p> While Vic Demone’s primary instrument is his song writing, his distinct voice and powerful performances have proven to be an undisputed force in his ability to engage with the audience.
</p>";
$homepage->Display();
?>Code: Select all
<?php
class Page
{
// class Page's Attributes
public $content;
public $title = 'Vic Demone';
public $keywords = 'Vic Demone, music, band, Dror, Mohar';
public $stylesheet = 'vicDemone.css';
// class Page's Operations
public function __set($name, $value)
{
$this->$name = $value;
}
public function Display()
{
echo "<html>\n<head>\n";
$this -> DisplayHead();
echo "</head>\n<body>\n<div id=\"main\">";
$this -> DisplayNav();
$this -> DisplayContent();
$this -> displayFooter();
echo "\n</div>\n</body>\n</html>\n";
}
public function DisplayHead()
{
echo ' <title>'.$this->title.'</title>
<meta name="keywords" content="'.htmlentities($this->keywords).'" />
<link rel="stylesheet" type="text/css" href="'.$this->stylesheet.'" />';
}
public function DisplayNav()
{
require('nav.php');
}
public function DisplayContent()
{
echo ' <div id="content">
'.$this->content.'
</div>';
}
public function DisplayFooter()
{
require('footer.php');
}
}
?>I know some of the code may seem a bit basic or badly written, but I'm new!
Can anyone help me out?
Thanks
Henry