Code executed only if .php is not include/require'd

From: Date: Sun, 04 Jun 2000 11:48:34 +0000
Subject: Code executed only if .php is not include/require'd
Groups: php.general 
Request: Send a blank email to php-general+get-969@lists.php.net to get a copy of this message
Is there a way to have a snippet of code (in my case, call a wrapper around show_source) execute only if a normally include/required file is *not* inclede/require'd? Example: I have a mypage.php which contains the class MyPage. This class is only useful if called by other .php files. I would like to have mypage.php, if called directly (ie, via http://docwhat.gerf.org/include/mypage.php ) then it will call show_source on itself. Is this possible? I was thinking, worst case, something like this: if( '/include/mypage.php' != $SCRIPT_NAME ) { show_source ..... } But I don't really like it for maintainability reasons. Can I get the filename directly (sort of like $0 in perl and sh)? Thanks. Ciao! -- "No one will ever win the battle of the sexes; there's too much fraternizing with the enemy.." -- Henry Kissinger The Doctor What: Not that 'who' guy http://docwhat.gerf.org/ docwhat@gerf.org KF6VNC

« previous php.general (#969) next »