I have a page that has a link to my day.php page. The link is <a href="day.php">this day</a> and it is supposed to create a text file with today's day of the week on it. For example, the text file would only have the word Monday on it, because I am asking this question on a Monday. Right now, it creates the text file and writes the day of the week properly. My problem is that it is surrounding the day of the week in HTML code.
Here is my day.php page code:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<?php
header('Content-type: application/txt');
header('Content-Disposition: attachment; filename="day.txt"');
echo date("l");
echo "\r\n";
?>
</body>
</html>
Here is what I get in my created text file, day.txt:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
Monday
</body>
</html>
When all I want is Monday.
If anyone knows the solution to my problem that would be greatly appreciated. Thank you for any help.
headers()functions above HTML code. Anyway, why don't you just remove all the HTML code? It is unnecessary.