note 69819 deleted from function.file by colder
| From: | colder@php.net | Date: | Fri, 22 Sep 2006 10:51:00 +0000 |
| Subject: | note 69819 deleted from function.file by colder | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-117413@lists.php.net to get a copy of this message | ||
Note Submitter: robrohan at gmail dot com
Reason: in docs
----
There is nothing on there that shows how to just do a simple basic authentication type request. You
use 'user@password' in the url itself. For example:
<?php
// Get a file into an array. In this example we'll go through HTTP to get
// the HTML source of a URL.
$lines = file('http://user:password@example.com/client/atom.xml');
// Loop through our array, show HTML source as HTML source; and line numbers too.
foreach ($lines as $line_num => $line) {
echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) .
"<br />\n";
}
// Another example, let's get a web page into a string. See also file_get_contents().
$html = implode('', file('http://www.example.com/'));
?>