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

search for in the

Glob> <Flux compressés
Last updated: Fri, 20 Jun 2008

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)
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> <Flux compressés
Last updated: Fri, 20 Jun 2008
 
 
show source | credits | sitemap | contact | advertising | mirror sites