?
Solved

shortest code to open a web page from PHP

Posted on 2007-10-09
4
Medium Priority
?
1,045 Views
Last Modified: 2013-12-13
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?
0
Comment
Question by:lucavilla
  • 2
  • 2
4 Comments
 
LVL 48

Expert Comment

by:hernst42
ID: 20041493
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"));'
0
 

Author Comment

by:lucavilla
ID: 20070872
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?
0
 
LVL 48

Accepted Solution

by:
hernst42 earned 2000 total points
ID: 20070889
ok for windows the quotes must be changed to:

php.exe -r "file_put_contents('destination.html', file_get_contents('http://www.example.com'));"
0
 

Author Comment

by:lucavilla
ID: 20070992
it works. THANKSSSSSSSSSSSSSS A LOT!!!!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses
Course of the Month16 days, 1 hour left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question