I was trying to use some code I found to create a template for my website. The code seems very simple but having no experience with php I'm coming up short on how to use it.
In a template page it has this...
<?php function render_page() { ?>
<html>
<head>
<title><?php echo $title ?></title>
<meta name="description" content="<?php echo $desc ?>">
<meta name="keywords" content="<?php echo $keywords ?>">
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
<body>
<!-- Layout code goes here -->
<?php echo body_text(); ?>
<!-- Layout code goes here -->
</body>
<?php } ?>
And in the content pages it has this
<?php
include("template.php");
$title = "This is the Title of the page";
$desc = "This is the META description of the page";
$keywords = "This is the META keywords of the page";
function body_text() {
// content of the page goes here
}
render_page();
?>
There are several problems. First, variables assigned in the content page are not printed. If I define them as a constant...
define("TITLE", "This is the Title of the page");
and call them as a constant...
<title><?php echo TITLE; ?></title>
... they show up correctly but I don't know why they don't show up when defined as a variable.
Also, where it says "//content of the page goes here" I can't put any content there without an error message being generated.
I'm extremely new to this. Any help in getting this to work is greatly appreciated.