There are several forms, one of them is with the function fwrite
php native:
$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 function exec
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 only overwrites what is inside the file, the second, adds with a line break
Save as? Take the contents of div and save where? on the server as HTML page?
– user60252
This, simply save to any . html file inside the same server.
– Linces Marques
Another thing, this div is on another page?
– user60252
It’s on the same page.
– Linces Marques