|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2005-12-30 07:43 UTC] sqchen at citiz dot net
Description:
------------
stream_copy_to_stream() do strange behavior when the maxlength parameter is negative, see the following codes:
Reproduce code:
---------------
<?php
$src = fopen("1.txt", "r"); //"hell, world" in "1.txt"
$dest1 = fopen("des1.txt", "w");
$dest2 = fopen("des2.txt", "w");
/*----seg1------*/
stream_copy_to_stream($src, $des1, -2);
readfile("des1.txt"); //hello, world
stream_copy_to_stream($src, $des1);
readfile("des2.txt"); //nothing? why?
/* please compare it with seg2*/
/*----seg2-------*/
stream_copy_to_stream($src, $des1, 2);
readfile("des1.txt"); //he
stream_copy_to_stream($src, $des1);
readfile("des2.txt"); //hello, world
?>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 06:00:02 2025 UTC |
SORRY, I have make a mistake on the code above, Below is the right code Description: ------------ stream_copy_to_stream() do strange behavior when the maxlength parameter is negative, see the following codes: Reproduce code: --------------- <?php $src = fopen("1.txt", "r"); //"hell, world" in "1.txt" $dest1 = fopen("des1.txt", "w"); $dest2 = fopen("des2.txt", "w"); /*----seg1------*/ stream_copy_to_stream($src, $des1, -2); readfile("des1.txt"); //hello, world stream_copy_to_stream($src, $des2); readfile("des2.txt"); //nothing? why? /* please compare it with seg2*/ /*----seg2-------*/ stream_copy_to_stream($src, $des1, 2); readfile("des1.txt"); //he stream_copy_to_stream($src, $des2); readfile("des2.txt"); //hello, world ?>stream_copy_to_stream() does not copy from sockets $s=stream_socket_server('tcp://127.0.0.1:1100',$er,$es); while($c=stream_socket_accept($s,200)){ $dat=fopen('text.txt','w'); stream_copy_to_stream($c,$dat); } PHP 5.1.4 (cli) GNU/Linux 2.6.16.18