Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting the contents of URL to a variable

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
What is the best way to get the contents of a file to a variable? And how can I prevent it from opening a local file (I want to open just URLs)?
 
Try this:

[tt]
$page = fopen(page.txt, "r") or die ("can't open file");
[/tt]

That will read the entire contents of page.txt into the variable $page.

To get it from a URL, you can do something like this:

[tt]
$url = "$page = fopen($url, "r") or die ("can't open file");
[/tt]

In case you are wondering, the "r" within the fopen functions means read only, while "w" mean write.

Hope this helps.

-Vic

vic cherubini
malice365@hotmail.com
====

Knows: Perl, HTML, JavScript, C/C++, PHP, Flash, Director

Wants to Know: Java, Cold Fusion, Tcl/TK

====
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top