Skip to content

cannot modify $_SERVER at builtin server #17737

@f2h2h1

Description

@f2h2h1

Description

In Apache and nginx environments, we can modify $_SERVER through configuration files

In CLI environments, we can modify $_SERVER through environment variables

but in builtin server ,
I canont modify $_SERVER through environment variables,
I canont find a way to modify $_SERVER,
I hope to find a way to modify $_SERVER in the builtin server

The following code:

test.php

<?php
echo isset($_SERVER['HTTPS']) ? '$_SERVER HTTPS exists' : '$_SERVER HTTPS not exists';
echo PHP_EOL;
echo !empty(getenv('HTTPS')) ? 'getenv HTTPS exists' : 'getenv HTTPS not exists';
echo PHP_EOL;

start builtin server

export HTTPS="on" php -S 127.0.0.1:8080
curl 127.0.0.1:8080/test.php

Resulted in this output:

$_SERVER HTTPS not exists
getenv HTTPS exists

But I expected this output instead:

$_SERVER HTTPS exists
getenv HTTPS exists

PHP Version

PHP 8.3

Operating System

Debian GNU/Linux 12 (bookworm)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions