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).
あなたはpathinfoを使うことができます:
$name = pathinfo($_SERVER['SCRIPT_FILENAME'], PATHINFO_FILENAME);
ただし、上記のコメント投稿者のアドバイスを参考にしてください:-)
$bname = basename($_SERVER['PHP_SELF']);
$name = rtrim($bname, '.php');
それが私にとってうまくいくことです。