Preparation for Studying API in PHP
When working with an API, there is always a site that provides this API and sites that use this API.
Let's create two test
sites on localhost: the site api.loc,
which serves the API, and the site tst.loc,
which accesses this API.
Let's test the joint work of these sites. Let the API site on the main page return some text:
<?php
echo 'test';
?>
Let's access this address from the test site and get the result:
<?php
$url = 'http://api.loc/index.php';
$res = file_get_contents($url);
var_dump($res);
?>
Create the two described sites and check their operation.