Including PHP files

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!

Moderator: General Moderators

Post Reply
Vasudhevan
Forum Newbie
Posts: 1
Joined: Wed Jul 06, 2011 5:36 am

Including PHP files

Post by Vasudhevan »

Dear Members

I am new to PHP. I design static pages using HTML. I am creating a PHP site. I have created two files as follows.

Header.PHP

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href=../CSS/Headerstyles.css" rel="stylesheet" type="text/css" />
</head>

<body>

<table width="100%" border="1">
<tr>
<td class="headerbackground"><a href="#" class="headerlink">Home</a></td>
</tr>
</table>
</body>
</html>

Home PHP

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<? php include ('Header.PHP');?>
<body>

<table width="100%" border="1">
<tr>
<td >&nbsp;</td>
</tr>
</table>
</body>
</html>

The above code done for including the Header.php file in the Home.php file is working in design time but not on runtime. Please suggest

Thanks in advance
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Including PHP files

Post by social_experiment »

Vasudhevan wrote:The above code done for including the Header.php file in the Home.php file is working in design time but not on runtime.
0.o What is the problem that you are having with the code? Remember that if you include a file, that whole file is included, meaning (in this case) you are getting multiple tags, double html headers which is maybe why you are having problems
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply