note 48949 added to function.include

From: Date: Wed, 12 Jan 2005 18:15:30 +0000
Subject: note 48949 added to function.include
Groups: php.notes 
Request: Send a blank email to php-notes+get-83161@lists.php.net to get a copy of this message
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"; ?> ---- Manual Page -- http://www.php.net/manual/en/function.include.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+48949 Delete -- http://master.php.net/manage/user-notes.php?action=delete+48949&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48949&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48949&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48949&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48949&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48949&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+48949&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#83161) next »