Jump to content

[SOLVED] Includes and Loading pages into variables - '1's appearing


Recommended Posts

Hi All,

 

Fairly new to php but not programming...

 

I want to load some php files into variables in the main page.. the files are pulled in ok,

however when echoing them out a '1' appears after each line. I think it might be returning a true as well? there are no '1''s in the included files. I want to load them into variables as will move to db driven pages afterwards. Any ideas?

 

See it in action at: www.royaldocks.net/bb/home.php

 

<?php

$headername = "component/header.php";
$footername = "component/footer.php";

/* Load all the files we need into variables then echo them out*/

  if(file_exists($headername)){
	/* go get it */
 $header =  require($headername);
}else{
	 $header =  "No Header";
}

if(file_exists($footername)){
	/* go get it */
 $footer =  require($footername);	
}else{
	 $footer =  "No Footer";
}


?>

<html>
<head>
</head>

<body>
<?php 
echo $header . "<br />";
echo "where are the nos coming from ?" . "<br />";
echo $footer . "<br />";

?>
</body>
</html>

 

 

Thanks Alastair

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.