-1

I could only find such a way that involved entering directories and stuff but what I want is so I can get the php filename (no extension or directory info) and use it as a var anywhere in any folder (using the include function to include the var).

4

2 に答える 2

2

あなたはpathinfoを使うことができます:

$name = pathinfo($_SERVER['SCRIPT_FILENAME'], PATHINFO_FILENAME);

ただし、上記のコメント投稿者のアドバイスを参考にしてください:-)

于 2012-07-06T04:02:15.947 に答える
0
$bname = basename($_SERVER['PHP_SELF']);
$name = rtrim($bname, '.php');

それが私にとってうまくいくことです。

于 2012-07-09T12:15:32.037 に答える