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

search for in the

Glob> <Flux compressés
Last updated: Fri, 14 Aug 2009

view this page in

Données (RFC 2397)

Le gestionnaire de flux data: (» RFC 2397) est disponible depuis PHP 5.2.0.

Exemple #1 Affichage du contenu de data://

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

Exemple #2 Récupération du type de média

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

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

Résumé du gestionnaire
Attribut Supporté
Restreint par allow_url_fopen Non
Restreint par allow_url_include Oui
Autorisé en lecture Oui
Autorisé en écriture Non
Autorisé en ajout Non
Autorisé en lecture et en écriture simutané Non
Supporte stat() Non
Supporte unlink() Non
Supporte rename() Non
Supporte mkdir() Non
Supporte rmdir() Non



add a note add a note User Contributed Notes
Données (RFC 2397)
sandaimespaceman at gmail dot com
07-Sep-2008 01:30
Now PHP supports data: protocol w/out "//" like data:text/plain, not data://text/plain,

I tried it.
togos00 at gmail dot com
08-Apr-2008 07: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> <Flux compressés
Last updated: Fri, 14 Aug 2009
 
 
show source | credits | sitemap | contact | advertising | mirror sites