源文件:
test.php
- <?php
- echo "The SCRIPT_FILENAME: ";
- echo $_SERVER['SCRIPT_FILENAME']."
";
- echo "The SCRIPT_NAME: ";
- echo $_SERVER['SCRIPT_NAME']."
";
- echo "The PHP_SELF: ";
- echo $_SERVER['PHP_SELF']."
";
- echo 'The __FILE__ : ';
- echo __FILE__."
";
- ?>
test2.php:
- <?php
- include("./test.php");
- echo "The end";
- ?>
结果:
1、直接执行
- The SCRIPT_FILENAME: /w/c/l/test.php
- The SCRIPT_NAME: /test.php
- The PHP_SELF: /test.php
- The __FILE__ : /w/c/l/test.php
2、执行
- The SCRIPT_FILENAME: /w/c/l/test2.php
- The SCRIPT_NAME: /test2.php
- The PHP_SELF: /test2.php
- The __FILE__ : /w/c/l/test.php
- The end
结论:__FILE__永远是自己所在的文件,其他的都是为别人做嫁衣!
另外,PHP_SELF将会得到pathinfo的部分。如test.php/abc=sd
还有一个'REQUEST_URI',将包含get来的参数,比如test.php?abc=1 ----end-----
阅读(3964) | 评论(0) | 转发(0) |