Link to home
Start Free TrialLog in
Avatar of lucavilla
lucavillaFlag for Italy

asked on

shortest code to open a web page from PHP

I have Windows Vista and PHP with Curl.
I would save a web page on my harddisk with a PHP command-line command. What's the more minimalist way to do it?
Avatar of hernst42
hernst42
Flag of Germany image

without using curl:
download.php
<?php
file_put_contents($_SERVER['argv'][2], file_get_contents($_SERVER['argv'][1]));

Then call the script to download
php.exe download.php http://www.example.com destination.html

or without any saved script:
php.exe -r 'file_put_contents("destination.html", file_get_contents("http://www.example.com"));'
Avatar of lucavilla

ASKER

C:\Program Files\PHP>php -r 'file_put_contents("test1.txt", file_get_contents("h
ttp://www.pippo.com"));'
PHP Warning:  Unexpected character in input:  ''' (ASCII=39) state=1 in Command
line code on line 1
PHP Parse error:  syntax error, unexpected $end in Command line code on line 1

C:\Program Files\PHP>php -r file_put_contents("test1.txt", file_get_contents("ht
tp://www.pippo.com"));
PHP Parse error:  syntax error, unexpected $end in Command line code on line 1

C:\Program Files\PHP>
________

What's the problem?
ASKER CERTIFIED SOLUTION
Avatar of hernst42
hernst42
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
it works. THANKSSSSSSSSSSSSSS A LOT!!!!