note 48949 deleted from function.include by nlopess

From: Date: Wed, 12 Jan 2005 21:29:30 +0000
Subject: note 48949 deleted from function.include by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-83172@lists.php.net to get a copy of this message
Note Submitter: lena at polho dot com ---- Sometimes you may want to include the same file in a number of scripts in different (levels of) directories. This is one way to include the absolute path: In index.php (or whatever the entry point is), which resides in the top-level directory of the site, you put <?php // this is index.php session_start(); // the following variable is the full path to the // directory in which this file is situated $_SESSION['site_root']= substr($script_filename,0,(strlen($_SERVER['SCRIPT_FILENAME'])-9)); //9 is the number of characters in "index.php" ?>. Then, when you call the include file: <?php include $_SESSION['site_root']."/include_dir/include_file.php"; ?>

« previous php.notes (#83172) next »