There are a number of ways, one of which is fwrite
native php:
$fp = fopen('data.html', 'w');
fwrite($fp, '<div>texto');
fwrite($fp, '<br>mais texto</div>');
fclose($fp);
The content of data.html is now <div>texto<br>mais texto</div>
If the server is on a linux you can use the exec
function to execute something like:
exec("echo '<div>texto' >> data.html");
exec("echo '<br>mais texto</div>' >> data.html");
// Ou
exec("echo '<div>texto<br>mais texto</div>' > data.html");
The difference between >
and >>
, is that the first just overwrites what's inside the file, the second, adds with a line break