如何在PHP中创建页面?

时间:2016-07-26 15:50:35

标签: php

PHP中是否有用于在PHP中创建页面的函数? 我会这样的:

create page("file.php", "<html><body><p>Hello!</p></body></html>");

如果我在site.it上运行它,它将使用<html><body><p>Hello!</p></body></html>创建site.it/file.php。

我可以这样做吗?

1 个答案:

答案 0 :(得分:-1)

您必须使用此功能:file_put_contents创建文件并将数据放入此文件

示例:

<?php
$file = 'people.txt';
// Open the file to get existing content
$current = file_get_contents($file);
// Append a new person to the file
$current .= "John Smith\n";
// Write the contents back to the file
file_put_contents($file, $current);
?>
相关问题