PHP readfile vs. file get contents
He utilizado el siguiente código para generar zip
// push to download the zip
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="'.$zip_name.'"');
readfile($zip_name);
Este código funciona bien, pero por razones desconocidas no estaba funcionando hasta que intenté
// push to download the zip
header('Content-type: application/zip');
header('Content-Disposition: attachment; filename="'.$zip_name.'"');
echo file_get_contents($zip_name);
Tengo curiosidad por encontrar lo que está sucediendo en ambos casos
24
1 answers
Readfile leerá el archivo directamente en el búfer de salida, y file_get_contents cargará el archivo en la memoria, cuando se hace eco del resultado los datos se copian de la memoria al búfer de salida con eficacia utilizando 2 veces la memoria de readfile.
42
Author: Jesper Blaase,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-11-20 11:55:43
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-11-20 11:55:43