To copy in PHP, as mentioned above, you can use the function copy()
which allows you to copy a file to another location or to another file because the input name does not have to be the same as the output name.
Example
Contents of the archive x.php
<?php
// Eu sou o arquivo X
echo "X é muita fixe, mas o bubu é mais fixe!";
?>
Contents of the archive y.php
<?php
// Eu sou o arquivo Y
// Vou criar um arquivo "z.php" e copiar para lá o arquivo "x.php"
copy("caminho/para/arquivo/x.php", "caminho/para/arquivo/z.php");
?>
The result of what the archive y.php
does is create a file with the name z.php
which will contain the contents of the file x.php
.
For example, I have a file x.php, and I have a file y.php, in this file y.php I want this to create a file z.php and make a copy to the file x.php, how can I do it?
– Gonçalo