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;
}
}
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'];
?>
| 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 |
Données (RFC 2397)
togos00 at gmail dot com
08-Apr-2008 09:56
08-Apr-2008 09:56
