I have written a simple mock API in apache (httpd, CentOS 7) web server using php. test.php
which is located in /var/www/html
is as below.
<?php
$age = '{"Peter":"Good", "Ben":37, "Joe":43}';
header('Content-Type: application/json');
sleep(5);
echo $age;
?>
When I call the API (http://<server_IP>:80/test.php
) in postman, it returns the exact same php code back.
When I run the php code on the server using php test.php
, it gets compiled correctly and returns expected output.
{"Peter":"Good", "Ben":37, "Joe":43}
Why don't I get this output when the API is invoked? How can I resolve this?