note 100979 added to wrappers.data
| From: | from dot php dot net at brainbox dot cz | Date: | Thu, 18 Nov 2010 12:37:52 +0000 |
| Subject: | note 100979 added to wrappers.data | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-174149@lists.php.net to get a copy of this message | ||
When passing plain string without base64 encoding, do not forget to pass the string through
URLENCODE(), because PHP automatically urldecodes all entities inside passed string (and therefore
all + get lost, all % entities will be converted to the corresponding characters).
In this case, PHP is strictly compilant with the RFC 2397. Section 3 states that passes data should
be either in base64 encoding or urlencoded.
VALID USAGE:
<?php
$fp = fopen('data:text/plain,'.urlencode($data), 'rb'); // urlencoded data
$fp = fopen('data:text/plain;base64,'.base64_encode($data), 'rb'); // base64
encoded data
?>
Demonstration of invalid usage:
<?php
$data = 'Günther says: 1+1 is 2, 10%40 is 20.';
$fp = fopen('data:text/plain,'.$data, 'rb'); // INVALID, never do this
echo stream_get_contents($fp);
// Günther says: 1 1 is 2, 10@ is 20. // ERROR
$fp = fopen('data:text/plain,'.urlencode($data), 'rb'); // urlencoded data
echo stream_get_contents($fp);
// Günther says: 1+1 is 2, 10%40 is 20. // OK
// Valid option 1: base64 encoded data
$fp = fopen('data:text/plain;base64,'.base64_encode($data), 'rb'); // base64
encoded data
echo stream_get_contents($fp);
// Günther says: 1+1 is 2, 10%40 is 20. // OK
----
Server IP: 147.32.160.17
Probable Submitter: 193.179.134.86
----
Manual Page -- http://www.php.net/manual/en/wrappers.data.php
Edit -- https://master.php.net/note/edit/100979
Del: integrated -- https://master.php.net/note/delete/100979/integrated
Del: useless -- https://master.php.net/note/delete/100979/useless
Del: bad code -- https://master.php.net/note/delete/100979/bad+code
Del: spam -- https://master.php.net/note/delete/100979/spam
Del: non-english -- https://master.php.net/note/delete/100979/non-english
Del: in docs -- https://master.php.net/note/delete/100979/in+docs
Del: other reasons-- https://master.php.net/note/delete/100979
Reject -- https://master.php.net/note/reject/100979
Search -- https://master.php.net/manage/user-notes.php