Forum Moderators: coopster
i simply want to display the contents of a text file in a html page, problem is ive handed this code over to a friend to use and the web host he uses produces an error because the include is directed sumwhere else? or sumthing like that his phpo is configured differently to mine?
what are the other options?
$text = "wordpad/tagline.txt"
echo ('$text');
i dunno im php newbie!
Thanks
config.php
// For UNIX:
ini_set('include_path', ini_get('include_path') . '.:' . $_SERVER['DOCUMENT_ROOT'] . '/../includes/');
// For Windows (paths are separated by semicolons, not colons):
ini_set('include_path', ini_get('include_path') . '.;' . $_SERVER['DOCUMENT_ROOT'] . '/../includes/');
Now you could keep the includes in their own directory, below the root. You can organize them however you want. For example you could have subdirectories within the main "include" directory separating scripts logically. Then, when you want to include any scripts, just include the config.php script first, then the rest will be found below the root, protected from the general public.
include($_SERVER['DOCUMENT_ROOT'] . "/config.php");
include("myscript.php");
include("subdir1/mynextscript.php");
include("subdir2/andyetanother.php");
The idea is to take a combination of built-in variables and server-specific paths and make sure that, on all servers you plan to run on, PHP will correctly resolve the paths.
I don't know whether that helps at all.