Система LinuxОшибка при вызове
Ищет помощь с моей функцией. Я начинаю их изучать. Было упомянуто, чтобы создать функцию, позволяющую не писать один и тот же код слишком много раз.
Я нашел много страниц о них, и они помогли, но у меня все еще возникают проблемы с работой.
Это не дает никаких ошибок журнала и ничего не создается. Я всегда получаю ошибки, когда начинаю с чего-то, поэтому я знаю, что чего-то не хватает.
Вот что у меня есть.
Заранее спасибо.
Боб
<?php
$dirPath = "Path to File Location";
$buildPath = "Path to File Location";
function createFiles() {
for ($i = 1; $i < 45; ++$i) {
$filename = $buildPath . '/$area'. sprintf("%02s", $i) . '.php';
if (!file_exists($buildPath$filename)) {
$myfile = fopen($buildPath$filename, "w") or die("Unable to open item$i file!");
fwrite($myfile, $txt1);
fwrite($myfile, $addtitle);
fwrite($myfile, $incltxt);
fclose($myfile);
chmod("$buildPath"."$area"."$i".".php", 0755);
}
// fopen, fwrite, fcloses...
// filename for delete page setup
if (!file_exists("$dirPath"."delete.page.php")) {
$myfile = fopen("$dirPath"."delete.page.php", "w") or die("Unable to open file!");
$txt = "<option value=\"\">Select Page to Delete......</option>\n
<option value=\"generalinfo.tx\">General Information Page.</option>\n
<option value=\"$filename\">$area Pg. $i</option>\n";
fwrite($myfile, $txt);
fclose($myfile);
chmod("$dirPath"."delete.page.php", 0755);
}
else
{
$myfile = fopen("$dirPath"."delete.page.php", "a") or die("Unable to open file!");
$txt = "<option value=\"$filename\">$area Pg. $i</option>\n";
fwrite($myfile, $txt);
fclose($myfile);
chmod("$dirPath"."delete.page.php", 0755);
}
break;
}
return true;
}
if ($i == 1) {
createFiles();
}
// Once we get more than 4 items written in each file we need a new file.
// This can happen maximum 11 times for each session
if ($i == 5) {
createFiles();
}
if ($i == 9) {
createFiles();
}
if ($i == 13) {
createFiles();
}
if ($i == 17) {
createFiles();
}
etc......
if($i == 49) {
echo "<br />Maximum of 12 pages hit. Time to delete a few";
}
?>
Какие ошибки у вас возникают? –
'$ buildPath $ filename' to' $ buildPath. $ Filename' –
Какое указание у вас есть, что это не работает должным образом? Какую попытку вы попытались сузить проблему? – David