Ver Mensaje Individual
  #5 (permalink)  
Antiguo 04/07/2007, 08:33
gustavo.morales
 
Fecha de Ingreso: junio-2007
Ubicación: Barranquilla
Mensajes: 24
Antigüedad: 16 años, 10 meses
Puntos: 0
Re: Leer archivos en PHP

Cita:
Iniciado por geq Ver Mensaje
si eso mismo

Código PHP:
$file="ruta/a/tu/archivo";
$cnt=file_get_contents($file);
$f=fopen($file,"w");
fwrite($f,"nuevo contenido para tu log\n".$cnt);
fclose($f); 
asi se ira escribiendo al comienzo del archivo

exitos
Muchísimas gracias no había leído el POST bien, ha funcionado a la perfección, quedo de la siguiente forma

Código PHP:
function addlog($type,$page,$event,$details){
    
$date date('Y-m-d');
    
$time date('H:i:s');
    
    
$logname 'logs/log'$date '.txt';    
    
$content file_get_contents($logname);
    
    
$file fopen($logname,'w');
    
fwrite($file"$type, $date, $time, $page, $event, $details" "\r\n" $content);
    
fclose($file);