$ _SERVER ['SCRIPT_NAME']问题

I'm currently learning PHP and from what I'm seeing $_SERVER ['SCRIPT_NAME']; contains the current script's path. However, any page I try to identify shows up as "/index.php".

For example, I will run this on about.php, but the results return "/index.php".

<?php
    $current_file = $_SERVER['SCRIPT_NAME'];
    echo $current_file;
?>

Obviously I'm missing something, but I don't see what it is.

Since your about.php is a template file that is at some point included in index.php, that is why you are getting /index.php as a result.

You should try using __FILE__:

The full path and filename of the file. If used inside an include, the name of the included file is returned. Since PHP 4.0.2, __FILE__ always contains an absolute path with symlinks resolved whereas in older versions it contained relative path under some circumstances.

'SCRIPT_NAME' Contains the current script's path. This is useful for pages which need to point to themselves. The __FILE__ constant contains the full path and filename of the current (i.e. included) file.

Excerpt from http://www.php.net/manual/en/reserved.variables.server.php

The php.net website documentation is very verbose with some excellent user comments. I would suggest that be your first stop for almost any question you have about php.