Bug #77253 [Opn->Fbk]: PHP_SELF value differs based on path to router script
| From: | cmb@php.net | Date: | Tue, 17 Aug 2021 11:59:00 +0000 |
| Subject: | Bug #77253 [Opn->Fbk]: PHP_SELF value differs based on path to router script | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-235898@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77253&edit=1
ID: 77253
Updated by: cmb@php.net
Reported by: andy at aiir dot com
Summary: PHP_SELF value differs based on path to router
script
-Status: Open
+Status: Feedback
Type: Bug
Package: Built-in web server
Operating System: *nix
PHP Version: 7.2.13
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
I cannot reproduce this with PHP-7.4 on Windows. Is this still an
issue for you with any of the actively supported PHP versions[1]?
[1] <https://www.php.net/supported-versions.php>
Previous Comments:
------------------------------------------------------------------------
[2018-12-06 16:59:55] andy at aiir dot com
Description:
------------
When running the PHP internal web server, the location of the router script affects the output of
the PHP_SELF value in an unusual way.
If I run PHP from the folder with the script in:
$ php -S 0:8080 index.php
And then call http://localhost:8080/, the value for PHP_SELF
is
/index.php. If I run the script from a parent directory (or any other location that
differs from the script), e.g.:
$ php -S 0:8080 src/index.php
The value for PHP_SELF when request http://localhost:8080/foo/bar will be
/foo/bar.
I'm not certain if this behaviour is intentional or not, but if it is, why is it this way? We
noticed this issue because it breaks a lot of popular routing libraries as they strip the content of
PHP_SELF from the variable they discern the path from, so it fails to route requests correctly.
Test script:
---------------
<?php echo $_SERVER['PHP_SELF'];
Expected result:
----------------
Expect the PHP_SELF value to always provide a path to the script, not change between this and the
web requested path.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77253&edit=1