Doc #79467 [Ver]: file_put_contents can't create file with data:// wrappers
| From: | j7ur8 at qq dot com | Date: | Sat, 11 Apr 2020 16:13:51 +0000 |
| Subject: | Doc #79467 [Ver]: file_put_contents can't create file with data:// wrappers | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-17482@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79467&edit=1
ID: 79467
User updated by: j7ur8 at qq dot com
Reported by: j7ur8 at qq dot com
Summary: file_put_contents can't create file with data://
wrappers
Status: Verified
Type: Documentation Problem
Package: Streams related
Operating System: windows Linux
PHP Version: 7.4.4
Block user comment: N
Private report: N
New Comment:
but it dont create a file.
Previous Comments:
------------------------------------------------------------------------
[2020-04-11 15:49:47] cmb@php.net
It seems the docs are wrong: <https://3v4l.org/9HKq6>.
------------------------------------------------------------------------
[2020-04-11 15:22:04] peehaa@php.net
According to the docs https://www.php.net/manual/en/wrappers.data.php#refsect1-wrappers.data-options
writing is not supported so seems to be working as designed.
If anything it shouldn't say it wrote 4 bytes instead.
------------------------------------------------------------------------
[2020-04-11 15:11:31] j7ur8 at qq dot com
Description:
------------
file_put_contents ( string $filename , mixed $data [, int $flags = 0 [, resource $context ]] ) : int
1. above is the function details
2. And when the params of
filename in file_put_contents starts with data:// , php will
execute it successful, but create a file.
Test script:
---------------
<?php
echo file_put_contents('data://text/plain,cccc', 'data');
?>
Expected result:
----------------
4 ; and create a file names 'ccc'
Actual result:
--------------
4; and do not create any file.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79467&edit=1