PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Glob> <Secuencias de Compresión
Last updated: Fri, 22 Aug 2008

view this page in

Datos (RFC 2397)

La envoltura de secuencia data: (» RFC 2397) se encuentra disponible desde PHP 5.2.0.

Example #1 Imprimir los contenidos de data://

<?php
// imprime "I love PHP"
echo file_get_contents('data://text/plain;base64,SSBsb3ZlIFBIUAo=');
?>

Example #2 Obtener el tipo de medios

<?php
$da   
fopen('data://text/plain;base64,''r');
$meta stream_get_meta_data($da);

// imprime "text/plain"
echo $meta['mediatype'];
?>

Resumen de Envoltura
Atributo Soporte
Restricción por allow_url_fopen No
Restricción por allow_url_include Si
Permite Lectura Si
Permite Escritura No
Permite Adición No
Permite Lectura y Escritura Simultánea No
Soporte stat() No
Soporte unlink() No
Soporte rename() No
Soporte mkdir() No
Soporte rmdir() No



add a note add a note User Contributed Notes
Datos (RFC 2397)
togos00 at gmail dot com
08-Apr-2008 09:56
Note that the official data URI scheme does not include a double slash after the colon - that you must include it when making calls to PHP is an artifact of the designers' misunderstanding of URL syntax.

To automatically convert proper data URIs to ones understood by PHP, you can use code such as the following:

function convertUriForPhp( $uri ) {
    if( preg_match('/^data:(?!\\/\\/)(.*)$/',$uri,$bif) ) {
        return 'data://' . $bif[1];
    } else {
        return $uri;
    }
}

Glob> <Secuencias de Compresión
Last updated: Fri, 22 Aug 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites