Discussion:
difference between copy and strem_copy
Negin Nickparsa
2014-10-01 15:45:32 UTC
Permalink
what is the difference in copying data from the file rather than a stream?

stream_copy_to_stream — Copies data from one stream to another
copy — Copies file
Maciek Sokolewicz
2014-10-01 21:02:14 UTC
Permalink
Post by Negin Nickparsa
what is the difference in copying data from the file rather than a stream?
stream_copy_to_stream — Copies data from one stream to another
copy — Copies file
Well, simply put:

copy - copies an actual SYSTEM file from one place to another. Note
though that PHP just tells the system to copy it over. PHP itself does
not read the data or do anything with it.

stream_copy - takes a stream, which can be anything: file data, a tcp/ip
connection, zipped data, etc. and copies everything it can read from the
first stream to a 2nd stream.



---
This email is free from viruses and malware because avast! Antivirus protection is active.
http://www.avast.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Christoph Becker
2014-10-01 23:12:42 UTC
Permalink
Post by Maciek Sokolewicz
Post by Negin Nickparsa
what is the difference in copying data from the file rather than a stream?
stream_copy_to_stream — Copies data from one stream to another
copy — Copies file
copy - copies an actual SYSTEM file from one place to another. Note
though that PHP just tells the system to copy it over. PHP itself does
not read the data or do anything with it.
However, depending on the configuration the following may work fine:

copy('http://php.net/', './php.net.html');
--
Christoph M. Becker
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Carlos Medina
2014-10-01 21:19:45 UTC
Permalink
Post by Negin Nickparsa
what is the difference in copying data from the file rather than a stream?
stream_copy_to_stream — Copies data from one stream to another
copy — Copies file
The difference is:

stream_copy_to_stream —> Copies data from one stream to another
and copy —> Copies a file from System


Regards

Carlos
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Christoph Becker
2014-10-01 23:09:27 UTC
Permalink
Post by Negin Nickparsa
what is the difference in copying data from the file rather than a stream?
stream_copy_to_stream — Copies data from one stream to another
copy — Copies file
The most relevant difference is that copy() works with file *names*
(note, that this is not necessarily restricted to actual files, but
rather allows arbitrary streams[1]), and stream_copy_to_stream() works
with *resources* (i.e. already opened streams).

Another difference is that stream_copy_to_stream() is able to copy only
parts of a stream, whereas copy() always copies the complete file.

[1] <http://php.net/manual/en/intro.stream.php>
--
Christoph M. Becker
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Loading...