-
Notifications
You must be signed in to change notification settings - Fork 8k
Closed as not planned
Labels
Description
Description
I am building PHP from source and running php script on cli.
Trying to use apache_request_headers() , apache_response_headers() or getallheaders() functions are not available in my php script.
Fatal error: Uncaught Error: Call to undefined function apache_request_headers()
PHp Script
http_cli_server_start(__DIR__ . '/get_headers.inc');
$ctx = stream_context_create(array('http' => array('method' => 'POST', 'content' => 'foo', 'header' => array('Content-Type: text/html', 'Header1:Value1'))));
$content = @file_get_contents("http://localhost:" . PHP_HTTP_SERVER_PORT, false, $ctx);
$headers=apache_request_headers();
get_headers.inc is just a script which starts php executable with cmd
cmd = "exec {$php_executable} -t {$doc_root} -n $serverArgs -S " . PHP_HTTP_SERVER_ADDRESS;
$cmd .= " {$router}";
$cmd .= " 2>/dev/null";
$cmd .= " 1>/dev/null";
$handle = proc_open($cmd, $descriptorspec, $pipes, $doc_root);
As per docs, it claims it works in the Apache, FastCGI, CLI, and FPM webservers.
PHP Version
PHP 8.1
Operating System
Ubuntu22