Re: Referring to Parent Folders
| From: | Paul Furman | Date: | Fri, 13 Feb 2004 14:36:55 +0000 |
| Subject: | Re: Referring to Parent Folders | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-177602@lists.php.net to get a copy of this message | ||
Richard Davey wrote:
Why not set-up a variable in a common include file (something like $basedir = "/usr/home/vinny/public_html/php") and then you can just do this: include "$basedir/script.php";Here's what I use: -------------------------------------- HOME: -------------------------------------- http://localhost/ C:/_Paul/web/public_html C:/_Paul/web/phplib
/configuration
/screen
/utilities
/action
--------------------------------------
SCHOOL:
--------------------------------------
http://hills.ccsf.edu/~pfurma02/
/students/pfurma02/public_html
/students/pfurma02/phplib
/configuration
/screen
/utilities
/action
--------------------------------------
Here's my HOME path definitions:
--------------------------------------
<?php /*
INDEX.PHP
this is the only file sitting in public_html
it tells us the paths for the server we are running on
and nothing else
then it includes a config file
for the rest of the setup
*/
define ('LIBDIR', 'C:/_Paul/web/phplib');
define ('PUB_DIR', 'C:/_Paul/web/public_html');
define ('URL_DIR', 'http://localhost/');
define ('CONFIG_DIR', LIBDIR . '/configuration');
include (CONFIG_DIR . '/config.php');
?>
--------------------------------------
This file works at home and at school:
--------------------------------------
<?php /*
CONFIG.PHP
this is the first thing called from index.php
it sets up the remaining global constants
it checks the screen input
to redirect before anything goes wrong
then includes the "main" template
*/
define ('SCREEN_DIR', LIBDIR . '/screen');
define ('UTIL_DIR', LIBDIR . '/utilities');
define ('ACTION_DIR', LIBDIR . '/action');
$template = 'main.php'; # the template for the site$default_screen = 'home.php'; # the default screen # check which SCREEN to display if(isset($_REQUEST['SCREEN'])) { if(is_file(SCREEN_DIR . "/" . basename($_REQUEST['SCREEN']))) {
$SCREEN = basename($_REQUEST['SCREEN']);} else {
$SCREEN = $default_screen;} } else { $SCREEN = $default_screen; } if($SCREEN == 'main.php') { $SCREEN = 'home.php'; $_REQUEST['SCREEN'] = $SCREEN; } include (SCREEN_DIR . "/$template"); ?>