Php tutorial fopen function usage (open a file)In many times, we need to create files, especially when generating static pages. in php, we often use the fopen function to create files. It is used to append files when files exist, you can create a
This article mainly introduces the example of using the fopen () function to access remote files in PHP. This article describes the functions of the fopen function, the configuration problems required for using it, and timeout issues, the code
Fopen(PHP 3, PHP 4> = 4.0.0) fopen -- open the file or URL descriptionInt fopen (string filename, string mode [, int use_include_path])If filename starts with "http: //" (Case Insensitive), this function uses HTTP 1.0 to connect to open the
This article mainly introduces the example of using the fopen () function to access remote files in PHP. This article describes the functions of the fopen function, the configuration problems required for using it, and timeout issues, the code
Using PHP not only allows users to access server-side files through the browser, but also access files from other servers via protocols such as HTTP or FTP, and can use HTTP and FTP URLs instead of filenames in most functions that require a filename
Fopen functions are mostly used to read and write files in php, but are sometimes used to obtain files from remote servers. However, when using fopen to read remote files, you must enable allow_url_fopen.
Solution Process
First, the DNS problem is
PHP to the operation of the FTP summary is as follows, detailed see the official documents$ftp _conn=Ftp_connect("192.168.1.230") or die(' host error ');//Link FTP serverFtp_login($ftp _conn, "Lihailong", "123456") or die("Login Error");//log in to
Problem DescriptionAllow_url_fopen = onWhether to allow the treatment of URLs(Like http: // or ftp: //) as files.Allow_url_include = onWhether to allow include/require to open URLs(Like http: // or ftp: //) as files.In the local wamp test
H1>
(PHP 3, PHP 4 >= 4.0.0)
Fopen--Open a file or URL
Describe
int fopen (string filename, string mode [, int use_include_path])
If filename starts with "http://" (case insensitive), this function opens the specified server with an HTTP 1.0
Curl is used for crawling between internet pages, fopen is used to read files, and file_get_contents is used to get the content of static pages.
1. fopen/file_get_contents Each request will be re-made DNS query, and does not cache the DNS
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.