I was reading through the sitepoint book on php and mysql, and I was trying to write a simple template as per chapter 4 but I'm having a problem. A snippet of code is shown below, its probably something silly I'm doing wrong
// $page is decoded from url and is verified to be as expected
//... some other stuff
$title = '$page';
<?php echo $title; ?>
However the title is always blank - what am I doing wrong?
$page hasnt been defined as anything in your code, thats why its alway blank, I suspect the code in the book was more an example than a working model.
Add this line to the top of your index.php
$page = 'this is the page title';
you also want to remove the quotes around $page, that makes it a string not a variable
Variables aren't expanded in single quotes, not that quotes are needed here.
$title = $page;
thanks I think thats probably it, if its not I'll let you know.
Many thanks again!