0

I tried searching around to find an answer to this but to no avail.

I have a simples PHP script with the below code:

<?php
header("Content-Type: application/json");
echo "Hello";
?>

I then execute the file using the below command:

php -f index.php

and the output is:

Hello

My question is, is it possible to return the header I outputted using PHP, so my expected output would be something like:

Content-Type: application/json

Hello
Ben Osborne
  • 218
  • 4
  • 15

1 Answers1

1

You can achieve this by using php-cgi without the -f option:

php-cgi index.php
X-Powered-By: PHP/7.3.3
Content-Type: application/json

Hello
Ben Osborne
  • 218
  • 4
  • 15