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.";
}
?>
PHP include adds a number 1 - help
Moderator: General Moderators
-
shawngoldw
- Forum Contributor
- Posts: 212
- Joined: Mon Apr 05, 2010 3:38 pm
Re: PHP include adds a number 1 - help
Remove all of the echo's before require. just put require 'somefile'