How can I get the filename of the current executed script?
IE, i want the script go get it's own filename, formatted "file.ext", no folders or anything else where it's located, just the filename of the file.
How to get the filename of the current file
Moderator: General Moderators
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
try this
Mark
Code: Select all
<?
$file = basename ($_SERVER['PHP_SELF']);
echo "the script is called ".$file;
?>so you can try:PHP manual wrote: Table 4.1. A few "magical" PHP constants
Name Description
__LINE__ The current line number of the file.
__FILE__ The full path and filename of the file.
__FUNCTION__ The function name. (This was added in PHP 4.3.0.)
__CLASS__ The class name. (This was added in PHP 4.3.0.)
__METHOD__ The class method name. (This was added in PHP 5.0.0)
Code: Select all
echo basename(__FILE__);so
gives me the file running, ie; if i include 1file.php in 2file.php, it will output 2file.php? That's what i want, and I just wanna be sure before i go on with my scipt
.
Code: Select all
<?php
$file = basename ($_SERVER['PHP_SELF']);
?>- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK