-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>
。
我可以做到嗎?
在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>
。
我可以做到嗎?
你要使用此功能: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);
?>
PHP沒有我們所知道的任何概念的「頁面」 – George
PHP確實有一個文件的概念。是的,有一個功能可以創建文件並指定其內容。不過,這是你應該對Google採取的行動。 –
您可以很容易地使該功能。 'function create_page($ path,$ content){'... – chris85