From:             a dot panek at brainsware dot org
Operating system: Linux & Windows
PHP version:      5.4.15
Package:          Built-in web server
Bug Type:         Bug
Bug description:SCRIPT_NAME acts strange

Description:
------------
When sending a request that has a file extension OR the request doesn't go
to a 
index.php (a test.php, e.g.), the SCRIPT_NAME holds the URI instead of the
actual 
current script name as documented here 
http://php.net/manual/en/reserved.variables.server.php

"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."

So basically the built-in server doesn't act as documented except when you
use a 
file called "index.php" as router script and don't use a file extension in
your 
URI.

I tested this on Linux and Windows resulting in the exact same behaviour.

Test script:
---------------
<?php
# index.php
#
# php -S localhost:8080 -t. index.php
#
# curl -i -X GET -H 'Accept: application/json'
localhost:8080/something.json
# -> '/something.json'
# curl -i -X GET -H 'Accept: application/json' localhost:8080/something
# -> '/index.php
#
# php -S localhost:8080 -t. test.php
# -> always the uri

echo $_SERVER['SCRIPT_NAME'];

?>

Expected result:
----------------
/index.php

Actual result:
--------------
/something.json

-- 
Edit bug report at https://bugs.php.net/bug.php?id=64951&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=64951&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=64951&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=64951&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=64951&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=64951&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=64951&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=64951&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=64951&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=64951&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=64951&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=64951&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=64951&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=64951&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64951&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=64951&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=64951&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=64951&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64951&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=64951&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=64951&r=mysqlcfg

Reply via email to