Now PHP supports data: protocol w/out "//" like data:text/plain, not data://text/plain,
I tried it.
データ (RFC 2397)
data: (» RFC 2397) ストリームラッパーは、 PHP 5.2.0 以降で使用可能です。
例1 data:// の内容の表示
<?php
// "I love PHP" と表示します
echo file_get_contents('data://text/plain;base64,SSBsb3ZlIFBIUAo=');
?>
例2 media type の取得
<?php
$fp = fopen('data://text/plain;base64,', 'r');
$meta = stream_get_meta_data($fp);
// "text/plain" と表示します
echo $meta['mediatype'];
?>
| 属性 | サポートの有無 |
|---|---|
| allow_url_fopen で制約される | No |
| allow_url_include で制約される | Yes |
| 読み込み許可 | Yes |
| 書き込み許可 | No |
| 追加許可 | No |
| 同時読み書き許可 | No |
| stat() のサポート | No |
| unlink() のサポート | No |
| rename() のサポート | No |
| mkdir() のサポート | No |
| rmdir() のサポート | No |
データ (RFC 2397)
sandaimespaceman at gmail dot com
07-Sep-2008 01:30
07-Sep-2008 01:30
togos00 at gmail dot com
08-Apr-2008 07:56
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;
}
}
