Say you have 100 subpages, and each one contain your email address. You change your email address… and now you have to change it on 100 pages! That takes a lot of work and time. But, using PHP and variables, all you would have to do is edit one page and it will change the email on all the subpages.
The first thing you so is create a variables.php page. You can name it anything you want, of course, variables.php is a generic name. In it, you put your variables like this:
<?
$name =”Your Name”;
$url =”http://www.yourdomain.com”;
$email =”email@yourdomain.com”;
?>
You can add anything you want. Say you link to your FAQ on most pages for questions, you can add:
$faq =”faq/index.php”;
The next thing you have to do is include the variables page. It only works on a .php page. If you have a header.php page already, the new code would look like this:
<?php include(‘variables.php’);
include(‘header.php’);?>
If you don’t have a header.php page (or some variation like header.txt, header.inc), add this:
<?php include(‘variables.php’);?>
So, now where you want your email address, you put:
<?=$email?>
For name, you would put:
<?=$name?>
Whatever you named the variable in the variables.php file, you place between the
<?=$ and ?>
Page Views: 51 views



















