file_get_contents

(PHP 4 >= 4.3.0, PHP 5)

file_get_contents -- Lee un archivo entero en una cadena

Descripción

string file_get_contents ( string nombre_archivo [, bool usar_ruta_inclusion [, resource contexto]])

Función idéntica a file(), con la excepción de que file_get_contents() devuelve el archivo en una cadena. En caso de fallo, file_get_contents() devolverá FALSE.

file_get_contents() es el modo preferido para leer los contenidos de un archivo en una cadena. Esta función usa las técnicas de asignación de memoria que soporte su SO para incrementar su rendimiento.

Nota: Esta función es segura binariamente.

Sugerencia: Puede usar una URL como nombre de archivo con esta función si los fopen wrappers han sido activados. Consulte fopen() para más detalles sobre cómo especificar el nombre de fichero y Apéndice L una lista de protocolos URL soportados

Nota: Context support was added with PHP 5.0.0.

Aviso

When using SSL, Microsoft IIS will violate the protocol by closing the connection without sending a close_notify indicator. PHP will report this as "SSL: Fatal Protocol Error" when you reach the end of the data. To workaround this, you should lower your error_reporting level not to include warnings. PHP 4.3.7 and higher can detect buggy IIS server software when you open the stream using the https:// wrapper and will suppress the warning for you. If you are using fsockopen() to create an ssl:// socket, you are responsible for detecting and suppressing the warning yourself.

Vea también fgets(), file(), fread(), include(), y readfile().