Problem with displaying the code on the site [closed]

I have two php files. In the first file I’ve done connection to MySQL and displaying data from the database in an array. In the second file I’ve included this file using include or require or require_once. It worked except of html:5 code is displaying on a site. I don’t know how to fix that. Here’s second file code:

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);
require_once 'apiindex.php';
?>
<!DOCTYPE html>
<html lang="pl">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>API and AJAX</title>
</head>
<body>
    
</body>
</html>

This is an output on a site:

[{"id":"1","autor":"Adam Mickiewicz","tytul":"Pan Tadeusz","cena":"20.99"},{"id":"3","autor":"Adam Mickiewicz","tytul":"Dziady cz.3","cena":"20.99"}]<!DOCTYPE html>
<html lang="pl">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Przykład</title>
</head>
<body>
    
</body>
</html>

I’ve tried instead of php file did html file but it can’t read php code.