HI,
I am using the copy() function to download a web page as shown in this
example:
[php]
$userAgent = $_SERVER['HTTP_USER_AGENT'];
$context_options = array (
'http' => array (
'method' => 'GET',
'header'=> "User-Agent: $userAgent"
)
);
$context = stream_context_create($context_options);
copy("http://www.example.com", "test/test.html", $context);[/php]
However, contrary to the PHP document for the copy() function:
bool copy ( string $source , string $dest [, resource $context ] )
it returns the following error:
Warning: Wrong parameter count for copy() in /var/www/printer/
test2.php on line 17
The copy() works fine except when the third parameter is included but,
in this case it returns http code 403 because the User-Agent isn't
specified. Is it possible to include the third parameter hence,
resource $context as stated in the documentation, is this a bug, or is
there something wrong with my code?
I am using Ubuntu/Linux 7.04 and php 5.2.1.
Thanks,
Carl
www. gaihosa. com
Please enclose your posted code in [code] tags (See How to Ask a Question).
This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.
Please use [code] tags in future.
MODERATOR