任何人都知道如何通过PHP自动创建文件,所以当单击标签时它也有文件,它现在只是一个通过循环显示的路径。但是当你点击它时没有文件,当然,长话短说如何我也可以创建一个带循环的文件,所以所有链接都有通过fopen或其他东西创建的文件,就像它们都生成了路径一样。
<?php
function display_user_docs($doc_array) {
// set global variable, to test later if this is on the page
global $doc_table;
$doc_table = true;
?>
<br>
<form name="doc_table" action="delete_doc.php" method="post">
<table width="300" cellpadding="2" cellspacing="0">
<?php
$color = "#cccccc";
echo "<tr bgcolor=\"".$color."\"><td><strong>Documentations</strong></td>";
echo "<td><strong>Delete?</strong></td></tr>";
if ((is_array($doc_array)) && (count($doc_array) > 0)) {
foreach ($doc_array as $doc) {
if ($color == "#cccccc") {
$color = "#ffffff";
} else {
$color = "#cccccc";
}
echo "<tr bgcolor=\"".$color."\"><td><a class=\"all-doc-link\" href=\"".$doc.".php\">".htmlspecialchars($doc)."</a></td>
<td><input type=\"checkbox\" name=\"del_me[]\"
value=\"".$doc."\"></td>
</tr>";
}
} else {
echo "<tr><td>No documentation on record</td></tr>";
}
?>
</table>
</form>
<?php
}
?>
答案 0 :(得分:0)
您可以使用file_put_contents
在PHP中创建文件。
它有两个参数,第一个是要创建的文件的名称,第二个是放在文件内的内容。
例如,如果我想创建一个名为123.txt
的文件,其中包含hello world
,我会执行以下操作:
file_put_contents("123.txt", "hello world");
文件名可以包含斜杠/
,以便您可以指定要在其中创建文件的文件夹。因此,如果我想在文件夹123.txt
中创建abc
文件,我可以将abc/123.txt
作为文件名(只要abc
与PHP脚本位于同一文件夹中)。
您可以在PHP manual中找到有关file_put_contents
的更多信息。