2016-07-26 71 views
-4

在PHP中用PHP创建页面是否有一个函数? 我想类似的东西:如何在PHP中创建页面?

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

如果我在site.it运行它,它会创建site.it/file.php与<html><body><p>Hello!</p></body></html>

我可以做到吗?

+3

PHP没有我们所知道的任何概念的“页面” – George

+0

PHP确实有一个文件的概念。是的,有一个功能可以创建文件并指定其内容。不过,这是你应该对Google采取的行动。 –

+0

您可以很容易地使该功能。 'function create_page($ path,$ content){'... – chris85

回答

-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); 
?>