-2
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

4

2 回答 2

2
$fp = fopen("Business_Pages/". $username . '/' . $username . ".html", "w");
于 2013-03-30T00:56:23.717 回答
1

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);
于 2013-03-30T00:57:28.893 回答