CSS不希望包含在文件中

Im setting up a xampp php website with auto creating css for site (If site named xyz.php/html is created, then a css is created too). Unfortunatelly css doesn't want to include in website using php echo's and html tags. No error.

In style.php:

$arr = explode("/",$_SERVER['PHP_SELF']);
$style = "";
foreach ($arr as $key){
    if(strpos($key, ".php")){
        $style = str_replace(".php", "style.css", $key);
    }
}
if($fp = fopen($_SERVER['DOCUMENT_ROOT']."/TestPHP/".$addr,"wb+")){
    fwrite($fp,"body{background-color:#666;}");
    fclose($fp);
}
echo $addr = "lib/require/styles/".$style;
echo '<link href="'.$addr.'" rel="stylesheet">';

In index.php:

require_once 'lib/require/php/styles.php';

That's because the only HTML (as i can see in your code) doesn't have anything else than the style, no head, no body... Why don't you directly paste the HTML inside the file instead of making PHP echo it?