note 60885 added to function.include

From: Date: Thu, 19 Jan 2006 12:36:15 +0000
Subject: note 60885 added to function.include
Groups: php.notes 
Request: Send a blank email to php-notes+get-102088@lists.php.net to get a copy of this message
@ajsharp at gmail dot com To find out which script has included another, use the Server Variable 'SCRIPT_NAME' (note: there are other server variables that also contain the script name, but I use this one simply because it works for me) e.g. "variables.php" <?php $includer = basename($_SERVER['SCRIPT_NAME']); switch ($includer) { case 'a.php': $this_variable = 'included by script a.php'; break; case 'b.php': $this_variable = 'included by script b.php'; break; default: $this_variable = 'included by unkown script'; } echo $this_variable; ?> Test with 3 different files "a.php", "b.php", "c.php", all with the same content: <?php include 'variables.php'; ?> ---- Server IP: 85.116.0.130 Probable Submitter: 86.136.129.99 ---- Manual Page -- http://www.php.net/manual/en/function.include.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60885 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60885&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60885&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60885&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60885&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60885&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60885&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60885&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60885&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#102088) next »