Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP复制和重命名文件_Php_Html - Fatal编程技术网

PHP复制和重命名文件

PHP复制和重命名文件,php,html,Php,Html,我有一个文件,我正试图移动,我可以这样做,但我似乎无法改变文件名的确切方式,我需要它 $file1 = "/../../../../../../rooms.GENRE.FILENAME/FILENAMEentry.html"; $newfile1 = "/../../../../creative/$path/ $dir entry.html"; copy($file1, $newfile1); $dir是带有我调用的文件名的变量。 这会将文件名返回为FILENAME entry.html,我需

我有一个文件,我正试图移动,我可以这样做,但我似乎无法改变文件名的确切方式,我需要它

$file1 = "/../../../../../../rooms.GENRE.FILENAME/FILENAMEentry.html";
$newfile1 = "/../../../../creative/$path/ $dir entry.html";
copy($file1, $newfile1);
$dir
是带有我调用的文件名的变量。 这会将文件名返回为
FILENAME entry.html
,我需要删除它们之间的空格

我已经试过了,没有空间

$direntry.html
移动并创建文件,但只将其命名为.html


基本上,我正在用
$dir
中的文件名替换文件名
FILENAMEentry.html
(大写部分):

$newfile1 = "/../../../../creative/$path/" . $dir . 'entry.html';

考虑使用串联:

$newfile1 = "/../../../../creative/$path/" . $dir . 'entry.html';
您是否尝试过:

$newfile1=“/../../../../../creative/$path/{$dir}entry.html”

您是否尝试过:


$newfile1=“/../../../../../creative/$path/{$dir}entry.html”

实际上$dir在回显时起作用,但是你有空间,如果你把它们写在一起,单词将是
$direntry
,这对解释器来说是不明确的,所以使用连接。 改变


实际上,$dir在回显时起作用,但是你有空间,如果你把它们写在一起,单词将是
$direntry
,这对解释器来说是不明确的,所以使用连接。 改变


你应该看看这些

这应该很好:

$file1 = "/../../../../../../rooms.GENRE.FILENAME/FILENAMEentry.html";
$newfile1 = "/../../../../creative/$path/".$dir."entry.html";

if (!copy($file1, $newfile1)) {
    echo "failed to copy file.";
}

斯蒂芬·克莱

<?php 
"{$str1}{$str2}{$str3}"; // one concat = fast
  $str1. $str2. $str3;   // two concats = slow
?>

使用双引号连接两个以上的字符串,而不是多个“.”运算符。PHP被迫与每个“.”运算符重新连接


你应该看看这些

这应该很好:

$file1 = "/../../../../../../rooms.GENRE.FILENAME/FILENAMEentry.html";
$newfile1 = "/../../../../creative/$path/".$dir."entry.html";

if (!copy($file1, $newfile1)) {
    echo "failed to copy file.";
}

斯蒂芬·克莱

<?php 
"{$str1}{$str2}{$str3}"; // one concat = fast
  $str1. $str2. $str3;   // two concats = slow
?>

使用双引号连接两个以上的字符串,而不是多个“.”运算符。PHP被迫与每个“.”运算符重新连接


这很有道理,我缺少的是连接。谢谢你,丹雅。如果允许的话,我会在5分钟内接受答案。这很有道理,我错过了连接。谢谢你,丹雅。如果允许的话,我会在5分钟内接受答案。谢谢你,玛拉。我不知道该如何写,但我遗漏了连接。谢谢你,谢谢你,玛拉,我不知道该怎么写,我缺少的是连接。谢谢你。谢谢你提供的这个资源,我现在正在浏览并感谢它,你是正确的,它肯定有效。谢谢你提供的这个资源,我现在正在浏览并感谢它,你是正确的,它肯定有效。