Portál AbcLinuxu, 6. května 2025 23:03
$fp=fopen('php://stdin', 'r'); $a = fread($fp,10000); fclose($fp);myslite, ze pouziti stream_get_contents misto fread by pomohlo ?
Buď to a nebo opakované načtení pomocí fread()
v cyklu. V dokumentaci je na to výslovné upozornění a jsou tam i dva příklady, jak to řešit:
When reading from anything that is not a regular local file, such as streams returned when reading remote files or frompopen()
andfsockopen()
, reading will stop after a packet is available. This means that you should collect the data together in chunks as shown in the examples below.
<?php // For PHP 5 and up $handle = fopen("http://www.example.com/", "rb"); $contents = stream_get_contents($handle); fclose($handle); ?>
<?php $handle = fopen("http://www.example.com/", "rb"); $contents = ''; while (!feof($handle)) { $contents .= fread($handle, 8192); } fclose($handle); ?>
Tiskni
Sdílej:
ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.