如何创建目录然后使用变量将文件写入该目录

mkdir("Business_Pages/".$username);
$fp = fopen("Business_Pages/$username".$username".html", "w");

fwrite($fp, "<html> <head> <link rel='stylesheet' href='index.css'>  </head </html>");

fclose($fp);

Im trying to make a directory in Business_Pages that works but im also creating a file in that newly created directory named what ever the name of the html input is. Im basically trying to the the variable $username at the end of the pathname but that doesnt work

$fp = fopen("Business_Pages/". $username . '/' . $username . ".html", "w");

You have some syntax errors in your code.

$contents = "<html> <head> <link rel='stylesheet' href='index.css'>  </head </html>"

$dir = "Business_Pages/$username";
if (!is_dir($dir))
    mkdir($dir);

$filename = $username . '.html';

file_put_contents($dir . '/' . $filename, $contents);