Page 1 of 1
Setting up to use .txt files as includes
Posted: Thu Oct 23, 2003 11:20 am
by eCentric
I have gone to the Apache web site and it does not help. I've changed my Options to "Options +Includes" as they instructed and it still doesn't work. Does anyone else know how to set up includes so that when you use "require" or "include" that you can include a .txt as file extension?
Code: Select all
<?php
require ('2004/includes/footer_2004.txt')
?>
THis doesn't work on my server. ( Apache 2.0.39 running PHP 4.2.2)
Any assistance would be greatly appreciated.
Posted: Thu Oct 23, 2003 12:11 pm
by volka
the apache's index settings do not affect on a local require().
Code: Select all
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
require ('2004/includes/footer_2004.txt');
?>
does this print any error message? And if: which?
Posted: Thu Oct 23, 2003 12:20 pm
by eCentric
Nope...no errors.
Posted: Thu Oct 23, 2003 12:44 pm
by Gen-ik
Also remeber that any PHP code in your includes still needs to have <? ?> tags around it.... even though it is being called into PHP.
I normally rename my include files with a .inc extension... and they work fine.
Posted: Thu Oct 23, 2003 2:36 pm
by eCentric
Good idea but that didn't work either.

Posted: Thu Oct 23, 2003 3:08 pm
by Gen-ik
This is a strange one.
What's in the file you are trying to include?
Posted: Thu Oct 23, 2003 4:21 pm
by eCentric
It's just html but I don't want to have to change it on all the pages....just in one place.
Posted: Thu Oct 23, 2003 5:19 pm
by Gen-ik
The only thing left that it might be then is that there's something wrong with the HTML. If you use require() PHP will spit out any errors so we know it's not a PHP problem.
Double check where you're including the file... as you probably know the require() needs to be put where you want the contents on the .txt file placed in the page.
Also make sure you haven't done something silly (like we all do now and again) such as missing out any opening or closing tags ( such as <tr><td></td></tr> ).
Don't do this for example....
Code: Select all
<table>
<tr>
<? require("thefile.txt") ?>
<td>
</td>
</tr>
</table>
You'll just have to make sure everything is where it's supposed to be.