User Contributed Notes: file
php@interfaces.fr
20-Jul-1999 04:15
Be careful using this function while operating on MacOS files !!!
As described in the "get_meta_tags" function (http://www.php.net/manual/function.get-meta-tags.php3), php uses a native function to parse input of files, so Mac files won't work on unix platform : -(
sean@devhype.com
24-Sep-1999 06:34
Store the contents of the file in a variable called $contents. Then use this line to pull out all of the links, but make sure to remove the href= /old?u=http%3A%2F%2Fwww.php.net%2Fmanual%2Fja%2Fout&y=1999 of each link in the array.
$tmp preg_match_all("|href=/old?u=http%3A%2F%2Fwww.php.net%2Fmanual%2Fja%2F%28%5B%24%2F%5C&y=1999'\"a-zA-Z0-9][^\s>\'\"]+)|i",$contents,$linksarray);
NOTE: $linksarray[0][0] is the first link returned and $linksarray[0][1] is the next, so on and so forth.
billgr@sunoptics.caltech.edu
04-Feb-2000 01:33
When using file() with remote files, it doesn't seem to like to get a file from the local host. That is, running it on the server host.com, it doesn't want to get "http://www.host.com/"
discoone@discoone.com
18-Feb-2000 12:24
Getting files on the same web server works perfectly.
I'm using this function to retrieve some files which URLs are stored in a mysql database. Thus the correct use of the function itself as i used is :
<pre>
$url = 'http://www.thehost.it/thepath/thefile.htm';
$allfile = file($url);
</pre>
giving the entire URL with HTTP:// and so on it seems to work, at least under BSD/OS v. 4.0.1 , Zend engine v.0.90, Apache/1.3.1 PHP/4.0b2.
davidbullock@tech-center.com
23-Feb-2000 03:23
If the retrieval of the file fails, then instead of the variable being set to an array, it will be set to a boolean.
If you are accessing a virtual host (ala Apache) with HTTP, be sure that the IP you are resolving to is one that the vhost is bound on.
anonymous
23-Feb-2000 07:21
To sean@devhype.com,
That was a good example for ripping links out of html. I praise you! God you're a PHP god. I visit gelicon.com all the time, your PHP tutorials rule!
stralud@libero.it
15-Mar-2000 11:43
ATTENTION!!
If you have:
$array = file("filename");
the last character of the array element is the newline char. So if you use the array elements remember it.
caspian@linuxfreak.com
22-Mar-2000 12:50
So what is the opposite of this function? What is the easiest way to dump an array to a file? i.e. in Perl you can just say
print FILEHANDLE @array;
mayur@morelinux.com
29-Mar-2000 10:13
How do I open multiple files (File names stored in a array) in W+ moed and overwirte them with NEW content patched on the old HTML files ? Contents are stored in a mysql database ....
Thanks in advance !
cleong@organic.com
22-Apr-2000 05:09
Use chop() to remove the newline/return characters from the end of the lines.
mars@redplanetsw.com
07-Jul-2000 02:31
Opposite of this function would be something like:
<PRE>print implode("", $array);</PRE>
implode() joins an array of strings into a single string.
ted@php.net
10-Jul-2000 01:32
Here's a way to put the contents of a file into a mail message:
<pre>
$msg="";
while ( list( $line_num, $line ) = each( $fcontents ) ) {
// Throw away the line number.
$msg .= $line; // Append the line to the message.
}
//echo $msg; //Just to see it; remove for production.
mail($to, $subject, $msg);
</pre>
dhickey@websitefactory.net
19-Jul-2000 12:51
You need to have PHP compiled with URL compliant fopen wrappers in order to use file on links.
25-Jul-2000 12:21
Does it support https,ssl ??
jay@webtechnw.com
25-Jul-2000 07:05
I need to parse a response from a webserver over https. A simple fopen statment seems to be close to what im looking for, however the default method is a GET request, where I must have a POST request. In short.. i need to post variables to a script on another server and then process its response.
php2eran@tromer.org
27-Jul-2000 12:47
In PHP 4.0.0 and lower, array elements are never longer than 8190 characters. Longer lines are split. This limitation was removed in PHP 4.0.1.
jay@webtechnw.com
27-Jul-2000 04:48
Problem solved.. If you are looking for a way to..Have PHP make an SSL encrypted post to a transaction server?
Use cURL. example..
http://www.faqts.com/knowledge-base/view.phtml/aid/697/fid/105/lang/en
or just go to
http://curl.haxx.se/
micfur@hotmail.com
01-Aug-2000 03:50
Hi, I am getting this error returned :
Warning: File("http://www.php.net") - No such file or directory
when I try to use the 'file' function. Any ideas?
Thanks