PHP include adds a number 1 - help

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
hilla4g01
Forum Newbie
Posts: 1
Joined: Thu Aug 19, 2010 10:38 am

PHP include adds a number 1 - help

Post by hilla4g01 »

Hi

I'm just a quick bit of PHP to work out the day and week number, so that a school can show Today's Menu. I have the Menu as an HTML file and set the PHP code to include the correct one. This works, but the result also adds a number '1' at the end of the include. If I hard code the HTML into the echo statement, all is well. If I use the include or require, I get the number. It's right at the very end of the included file, and is not in any of the code. Help!

Code below.

<?php

$wk = date('W');
$day = date('l');

if ($day == "Saturday" || $day == "Sunday") {
echo "There is no weekend menu.";
}

elseif ($wk == "33" || $wk == "36") {

if ($day == "Monday") {
echo require 'lunches/wk1_monday.html';}
elseif ($day =="Tuesday") {
echo require 'lunches/wk1_tuesday.html';}
elseif ($day =="Wednesday") {
echo require 'lunches/wk1_wednesday.html';}
elseif ($day =="Thursday") {
echo require 'lunches/wk1_thursday.html';}
elseif ($day =="Friday") {
echo require 'lunches/wk1_friday.html';}
}

else {
echo "No Daily Menu available. Please see our Menu and Lunch pages for more details.";
}

?>
shawngoldw
Forum Contributor
Posts: 212
Joined: Mon Apr 05, 2010 3:38 pm

Re: PHP include adds a number 1 - help

Post by shawngoldw »

Remove all of the echo's before require. just put require 'somefile'
Post Reply