Merge branch 'PHP-7.4'

* PHP-7.4:
  Add php_cli_server_connect() helper
This commit is contained in:
Nikita Popov 2020-04-08 17:11:50 +02:00
commit b0d8f012f9
33 changed files with 83 additions and 251 deletions

View file

@ -1,7 +1,7 @@
<?php
define ("PHP_CLI_SERVER_HOSTNAME", "localhost");
define ("PHP_CLI_SERVER_PORT", 8964);
define ("PHP_CLI_SERVER_ADDRESS", PHP_CLI_SERVER_HOSTNAME.":".PHP_CLI_SERVER_PORT);
define("PHP_CLI_SERVER_HOSTNAME", "localhost");
define("PHP_CLI_SERVER_PORT", 8964);
define("PHP_CLI_SERVER_ADDRESS", PHP_CLI_SERVER_HOSTNAME.":".PHP_CLI_SERVER_PORT);
function php_cli_server_start(
?string $code = 'echo "Hello world";',
@ -96,4 +96,14 @@ php_cli_server_start_error:
return $handle;
}
function php_cli_server_connect() {
$timeout = 1.0;
$fp = fsockopen(PHP_CLI_SERVER_HOSTNAME, PHP_CLI_SERVER_PORT, $errno, $errstr, $timeout);
if (!$fp) {
die("connect failed");
}
return $fp;
}
?>