Forum Moderators: coopster

Message Too Old, No Replies

Echo and include returns everything + 1

         

sloth9

4:07 am on Oct 20, 2010 (gmt 0)

10+ Year Member



Hi, so I am designing a website and each page has the same menu, footer and meta info.

To cut down on the repetition, I've put all of this info into separate html files and recall them on each page using echo and include. Everything works ALMOST perfectly. The problem is that the include command returns a one after everything. This is my code:


<html><head><title>Title</title>
<?php
echo include("meta.html");
echo include("menu.html");
?>
test
<?php
echo include("footer.html");
?>


(all the tags are closed in the html files)

And my output looks like this:

<meta html></meta html>1
<menu html></menu html>1
test
<footer html></footer html>1

I've read the manual and understand why the one is there, but I can't figure out how to get rid of it!

IndiaMaster

4:33 am on Oct 20, 2010 (gmt 0)

10+ Year Member



I think just <?php include("menu.html");?> is enough. You don't need any echo.

Anyango

5:46 am on Oct 20, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



i agree, indiamaster is right. echo isnt needed before an include statement. If your menu.html has html code in it it will be placed there right away even without echo. If you have php variables in the included files then you can echo them on this page after including the file

Edit:
Sorry forgot to answer your main question, That 1 is there just because of the echo. Because the include statement gets executed true and hence echo prints 1. If you remove the echo that 1 will be gone

sloth9

6:45 am on Oct 20, 2010 (gmt 0)

10+ Year Member



Thanks, I'm kind of a newb so this really helps!