php-src icon indicating copy to clipboard operation
php-src copied to clipboard

Built-in web server prints HTML tags in terminal when address is wrong

Open MauricioFauth opened this issue 4 years ago • 2 comments

Description

I tried to start the built-in web server, but I mistyped the address and then the PHP cli printed HTML tags in the terminal.

- php -S 0.0.0.0:8080
+ php -S 0.0..0:8080

Resulted in this output:

$ php -S 0.0..0:8080
[Wed Dec 15 11:54:39 2021] PHP Warning:  Unknown: php_network_getaddresses: getaddrinfo for 0.0..0 failed: Name or service not known in Unknown on line 0
<br />
<b>Warning</b>:  Unknown: php_network_getaddresses: getaddrinfo for 0.0..0 failed: Name or service not known in <b>Unknown</b> on line <b>0</b><br />
[Wed Dec 15 11:54:39 2021] Failed to listen on 0.0..0:8080 (reason: php_network_getaddresses: getaddrinfo for 0.0..0 failed: Name or service not known)

But I expected this output instead:

$ php -S 0.0..0:8080
[Wed Dec 15 12:01:43 2021] PHP Warning:  Unknown: php_network_getaddresses: getaddrinfo for 0.0..0 failed: Name or service not known in Unknown on line 0
[Wed Dec 15 12:01:43 2021] Failed to listen on 0.0..0:8080 (reason: php_network_getaddresses: getaddrinfo for 0.0..0 failed: Name or service not known)

PHP version:

PHP 8.1.0 (cli) (built: Nov 25 2021 20:48:52) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.0, Copyright (c) Zend Technologies
    with Zend OPcache v8.1.0, Copyright (c), by Zend Technologies
    with Xdebug v3.1.1, Copyright (c) 2002-2021, by Derick Rethans
    with blackfire v1.72.0~linux-x64-non_zts81, https://blackfire.io, by Blackfire

PHP Version

8.1.0

Operating System

Debian Bookworm

MauricioFauth avatar Dec 15 '21 15:12 MauricioFauth

php-cli hard-codes a few ini settings. Those are currently not set for cli-server.

https://github.com/php/php-src/blob/78ef25b21c344b63ee66d53ce62dae5028df2688/sapi/cli/php_cli.c#L1319

https://github.com/php/php-src/blob/78ef25b21c344b63ee66d53ce62dae5028df2688/sapi/cli/php_cli.c#L128-L134

Not sure if all of those make sense for cli-server.

iluuu1994 avatar Dec 15 '21 17:12 iluuu1994

Usually you want html_errors with the built-in Webserver; it's only that such start-up errors should do without (although I don't consider this a big deal). Anyhow, this is very remotely related to https://bugs.php.net/72572.

cmb69 avatar Dec 15 '21 17:12 cmb69