The perfect implementation of PHP write, read, replace file content. First of all, the main use:
fopen ("filename. Extension", "How to")
Fwrite (Read the file, "write the File");
Fclose (open object variable);
Write file $str=
In PHP read and write files There are two more practical functions fopen fwrite function, there are two of them can be very good operation of the file, there is a need to see the detailed.
1.fopen (create file and open file)
Grammar:
fopen (filename,
Php file reading summary. One of the ways to deal with modern programming languages such as PHP is that there are plenty of options available. PHP can easily win the Perl motto "There lets us calculate how many methods There are
One of the fun of
C ++ File Operations
Address: http://www.layz.net/blog/user1/xuanxuan/archives/2006/67.htmlIn C ++, there is a stream class. All I/O is based on this "stream" class, including the file I/O we want to know, stream has two important operators:
1.
What if an exception occurs in fputs? Page prompt: AssemblycodeWarning: fputs () expectsparameter1toberesource, booleangivenloud. phponline100Warning: feof () expects fputs () what should I do if an exception occurs?
Page prompt:
Assembly code
A. standard file programming library functions for file state:#include 1.int ferror (file* stream);//is only used to determine whether the error occurred, not clear the wrong contentWhen the file IO error occurs, FERROR returns non 0, successfully
Let's figure out how many ways
One of the pleasures of dealing with modern programming languages such as PHP is that there are a number of options available. PHP can easily win Perl's motto "There's more than one ways to do it" (not the only way it
Linux-fopen-fclose-fread-fwrite and other functions
Clearerr (error flag for clearing file streams)
Related functions
Feof
Header file
# Include
Define functions
Void clearerr (File * stream );
Function Description
Clearerr () clears the error
1.2 file input and output functions
The input and output of logical devices, such as keyboards, monitors, printers, and disk drives, can be completed through file management. The most commonly used disk files are used for programming. Therefore,
PHP implements file reading and parsing functions similar to the C language,
This example describes how PHP implements file reading and parsing functions similar to the C language. We will share this with you for your reference. The details are as
In ansi c, file operations are divided into two methods: stream file operations and I/O file operations, which are described below.
I. Stream File OperationsThis file operation has an important structure file, which is defined in stdio. h as
In ansi c, file operations are divided into two methods: stream file operations and I/O file operations, which are described below.
I. Stream File Operations
This file operation has an important structure file, which is defined in stdio. h as
Fgets (read a string from the file)Related functions: open, fread, fscanf, GETCHeader file include Define the function char * fgets (char * s, int size, file * stream );Function Description: fgets () is used to read characters from the file referred
The code is as follows
Copy Code
$con = mysql_connect ("localhost", "root", "222222");if (! $con){Die (' Could not connect: '. Mysql_error ());}echo "Success"Mysql_close ($con); Close connectionVar_dump ($row); Print outPrint_r ();
fopen (Open file)Correlation function Open,fclose
Table header file #include
Defines the function FILE * fopen (const char * path,const char * mode);
The function description parameter path string contains the file path and filename to open, and
Let's count the number of ways
One of the pleasures of dealing with modern programming languages like PHP is that there are a number of options available. PHP can easily win Perl's motto "There ' more than one way to do it" (not only a single method
1.2 file input and output function keyboard, monitor, printer, disk drive and other logical devices, its input and output can be done through file management methods.
The most important to use in programming is disk files, so this section is
If you want to use the Fsockopen function we must set the Allow_url_fopen = on in the php.ini to the open state.
Cases
Fsockopen () Example
code is as follows
copy code
$fp = Fsockopen ("www.example.com",
Do read the file today to practice when encountered a problem, and then in Baidu to find relevant solutions. Found this article, I feel good, special reproduced over, for everyone's reference, I believe that we will have a different harvest.
The
the fopen function is used to open the file in PHP. The first parameter of this function contains the name of the file to be opened, and the second parameter specifies which mode to use to open the file;The file may be opened in the following mode:--
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.