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
1
  • @mario Thanks! I tried php-cgi but with the -f option, removed and it works! Commented Apr 3, 2019 at 12:40

1 Answer 1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.