1
I want to write a particular code on a particular line of a PHP file.
<?php
$arquivo_origem = "client.php";
$arquivo_destino = "copiado.php";
if (copy($arquivo_origem, $arquivo_destino)){
echo "Sucesso!";
}
$teste = "Eu sei";
$handle = fopen( $arquivo_destino, 'a+' );
$ler = fwrite( $handle, $teste );
// Fecha o arquivo
fclose($handle);
?>
I would like to write my variable $test on line 17 of my $file destination.
In the case as I do?
Good Morning, in my case I wanted to replace the line, but my complete code is like this: http://pastebin.com/Za4q4Sxq However it creates the file pastes the code but does not replace the line, can indicate me the error?
– Gonçalo
possibly because you are opening the file twice, the first in append mode on line 14 and then on line 21, remove line 14 ($Handle = fopen( $arquivo_destination, 'a+' );) and line 26 ($Handle = fopen( $arquivo_destination, 'a+' );)
– Adir Kuhn
Good Morning, It’s still the same print the file but it doesn’t replace the line.
– Gonçalo
here works of good
– Adir Kuhn
you can see an example here http://ideone.com/9XtaS5
– Adir Kuhn