Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

stream_copy_to_stream(3) [php man page]

STREAM_COPY_TO_STREAM(3)						 1						  STREAM_COPY_TO_STREAM(3)

stream_copy_to_stream - Copies data from one stream to another

SYNOPSIS
int stream_copy_to_stream (resource $source, resource $dest, [int $maxlength = -1], [int $offset]) DESCRIPTION
Makes a copy of up to $maxlength bytes of data from the current position (or from the $offset position, if specified) in $source to $dest. If $maxlength is not specified, all remaining content in $source will be copied. PARAMETERS
o $source - The source stream o $dest - The destination stream o $maxlength - Maximum bytes to copy o $offset - The offset where to start to copy data RETURN VALUES
Returns the total count of bytes copied. CHANGELOG
+--------+------------------------------+ |Version | | | | | | | Description | | | | +--------+------------------------------+ | 5.1.0 | | | | | | | Added the $offset parameter | | | | +--------+------------------------------+ EXAMPLES
Example #1 A stream_copy_to_stream(3) example <?php $src = fopen('http://www.example.com', 'r'); $dest1 = fopen('first1k.txt', 'w'); $dest2 = fopen('remainder.txt', 'w'); echo stream_copy_to_stream($src, $dest1, 1024) . " bytes copied to first1k.txt "; echo stream_copy_to_stream($src, $dest2) . " bytes copied to remainder.txt "; ?> SEE ALSO
copy(3). PHP Documentation Group STREAM_COPY_TO_STREAM(3)

Check Out this Related Man Page

STREAM_GET_CONTENTS(3)							 1						    STREAM_GET_CONTENTS(3)

stream_get_contents - Reads remainder of a stream into a string

SYNOPSIS
string stream_get_contents (resource $handle, [int $maxlength = -1], [int $offset = -1]) DESCRIPTION
Identical to file_get_contents(3), except that stream_get_contents(3) operates on an already open stream resource and returns the remain- ing contents in a string, up to $maxlength bytes and starting at the specified $offset. PARAMETERS
o $handle ( resource) - A stream resource (e.g. returned from fopen(3)) o $maxlength ( integer) - The maximum bytes to read. Defaults to -1 (read all the remaining buffer). o $offset ( integer) - Seek to the specified offset before reading. If this number is negative, no seeking will occur and reading will start from the current position. RETURN VALUES
Returns a string or FALSE on failure. CHANGELOG
+--------+-------------------------+ |Version | | | | | | | Description | | | | +--------+-------------------------+ | 5.1.0 | | | | | | | The $offset was added. | | | | +--------+-------------------------+ EXAMPLES
Example #1 stream_get_contents(3) example <?php if ($stream = fopen('http://www.example.com', 'r')) { // print all the page starting at the offset 10 echo stream_get_contents($stream, -1, 10); fclose($stream); } if ($stream = fopen('http://www.example.net', 'r')) { // print the first 5 bytes echo stream_get_contents($stream, 5); fclose($stream); } ?> NOTES
Note This function is binary-safe. SEE ALSO
fgets(3), fread(3), fpassthru(3). PHP Documentation Group STREAM_GET_CONTENTS(3)
Man Page

15 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

echo with stdin

Why doesnt echo output the contents of the file abc.txt as shown below ? chid@athena:~$ cat abc.txt sssss chid@athena:~$ echo < abc.txt chid@athena:~$ (6 Replies)
Discussion started by: systemsb
6 Replies

2. Shell Programming and Scripting

What syntax is required so that result will start from a new line..

What syntax is required to start the result in a new line (7 Replies)
Discussion started by: sapan123
7 Replies

3. Shell Programming and Scripting

creating files and getting input from another file

I have a file where i have files name with absolute path. Ex: files.dat and contents are: /root/xy/yz/zz/abc.txt /root/xx/yy/zz/ac.txt /root/xz/yz/zx/bc.txt /root/xy/yz/zx/abcd.txt now i want to create all above files(dummy files and can be 0 byte). i thought of using touch but it doesn't... (10 Replies)
Discussion started by: ajayyadavmca
10 Replies

4. UNIX for Dummies Questions & Answers

Replacing string

Hi there, I'd like to replace STRING_ZERO in FILE_ZERO.txt with the value of VALUEi-th by using something like that: VALUE1=1000 VALUE2=2000 VALUE3=3000 for((i=1;i<=3;i++)); do sed "s/STRING_ZERO/$VALUE'$i'/" FILE_ZERO.txt >> FILE_NEW.txt; done but it doesn't work... Any help... (9 Replies)
Discussion started by: Giordano Bruno
9 Replies

5. Shell Programming and Scripting

file transfer between two servers

Hi Frdz, Can any one help me out. I have a issue like below.i have to write shell script in unix. Server1 server2 ====== ======= 1.txt 1.txt 2.txt 3.txt I have to copy the files from server1 to server2 only... (6 Replies)
Discussion started by: KiranKumarKarre
6 Replies

6. UNIX for Dummies Questions & Answers

script in Bash 2.05b.0(1) and 3.2.25(1) Red Hat

Hi I have this script #!/bin/bash cat status.txt | while read LINE do linija="$LINE" echo $linija echo $linija | awk '{print $1}' > temp.txt koj=`tail -1 temp.txt` echo $koj echo $linija | awk '{print $2}' > temp1.txt kolku=`tail... (7 Replies)
Discussion started by: Ruzeil
7 Replies

7. Shell Programming and Scripting

Help with shell script: moving end of line character

Hello. I have a file (old.txt) that I need to copy into another file (new.txt). Each line on old.txt ends with CR/LF but the position of CR/LF varies from one record to another. I need to copy each line of record to new.txt and move CR/LF in pos 165. Can I use awk to achieve this? How?... (8 Replies)
Discussion started by: udelalv
8 Replies

8. Shell Programming and Scripting

Compare 2 files

Hi I have, 2 files with only one column in each file . f1.txt a b c f2.txt a b c d e f d (11 Replies)
Discussion started by: kanakaraju
11 Replies

9. Shell Programming and Scripting

How to count number of occurances of string in a file?

Gurus, Need little guidance. I have A.txt and B.txt file. B.txt file contains Unique strings. Sample content of B.txt file for which i cut the fourth column uniquely and output directed to B.txt file And A.txt file contains the above string as a fourth column which is last column. So A.txt... (7 Replies)
Discussion started by: Shirisha
7 Replies

10. Shell Programming and Scripting

if file is NOT empty, then append content to file

hi people, i have texts down.txt and down-new.txt and i want to check; - if down-new.txt is NOT empty, then write date and its content to /home/gc_sw/down.txt for example; down.txt:AAAA SSSS down-new.txt:123 456 and after checking down-new.txt is NOT empty, down.txt should... (10 Replies)
Discussion started by: gc_sw
10 Replies

11. AIX

Rows manupulation using AWK or sed

Hi Everyon, I am stuck in a script.I have a file named file1.txt as given below: It contains 2 columns-count and filename. cat file1.txt count filename 100 A_new.txt 1000 A_full.txt 1100 B_new.txt 2000 B_full.txt 1100 C_new.txt 2000 C_full.txt ................... ..................... (10 Replies)
Discussion started by: rajsharma
10 Replies

12. Shell Programming and Scripting

Want to read data from a file name.txt and search it in another file and then matching...

Hi Frnds... I have an input file name.txt and another file named as source.. name.txt is having only one column and source is having around 25 columns...i need to read from name.txt line by line and search it in source file and then save the result in results file.. I have a rough idea about the... (15 Replies)
Discussion started by: ektubbe
15 Replies

13. Shell Programming and Scripting

Shell Scripting

Hello , Can any one suggest me that how copy only 3 characters and not more than that starting from "an" As below angio.txt anbel.jpg anheakla.txt when i try to copy anheakla.txt should not get copied . can some one suggest me ? (7 Replies)
Discussion started by: sankar91
7 Replies

14. Shell Programming and Scripting

Match or no match

Not sure if my attempt below is close but I am trying to match $1 of gene.txt to $2 of medicalexome.txt, and if there is a match then $2 $1 are copied to a new result.txt which is tab-delimited. If no match is found then $1 of gene.txt and "No Match" are copied to the result file. awk... (9 Replies)
Discussion started by: cmccabe
9 Replies

15. UNIX for Beginners Questions & Answers

Copy the content from txt file and create a html file

I have a txt file with a list of error messages in a xml tag format, and each error message is separated with a identifier(endresult).Need to split that and copy and create a new html file.Error message has some special character. how to escape the special character and insert my data into the... (7 Replies)
Discussion started by: DevAakash
7 Replies