PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Hello guys and girls... I have a problem trying to create a simple text file... it doesn't want to be created... It just return that can't write or can't be created..
I have tried with the example of fwrite from http://www.php.net and even that example fails...
<?php
$nombre_archivo = 'prueba.txt';
$contenido = "Agregar esto al archivo\n";
if (is_writable($nombre_archivo)) {
if (!$gestor = fopen("$nombre_archivo", 'a')) {
echo "No se puede abrir el archivo ($nombre_archivo)";
exit;
}
if (fwrite($gestor, $contenido) === FALSE) {
echo "No se puede escribir al archivo ($nombre_archivo)";
exit;
}
echo "Éxito, se escribió ($contenido) al archivo ($nombre_archivo)";
fclose($gestor);
}
else {
echo "No se puede escribir sobre el archivo $nombre_archivo";
}
?>