刚才我学习了如何在服务器中创建新目录。所以我的问题是,是否可以将PHP文件复制到创建的新目录中?
以下是我提出的
mkdir('/home/user/public_html/ref/' . $cid . "_" . $gid, 0777);
copy('/home/user/public_html/ref/index.php' ,'/home/user/public_html/ref/' . $cid . "_" . $gid);
您使用copy()
是正确的,请参阅此处的PHP文档副本。
他们提供的例子是…
<?php
$file = 'example.txt';
$newfile = 'example.txt.bak';
if (!copy($file, $newfile)) {
echo "failed to copy $file...'n";
}
?>
您的语法不正确,因为copy()
中的2参数需要是没有目录的文件名(如上面的示例所示(。所以试试这个。
mkdir('/home/user/public_html/ref/' . $cid . "_" . $gid, 0777);
copy('/home/user/public_html/ref/index.php' ,'/home/user/public_html/ref/' . $cid . "_" . $gid . '/index.php');