Several ways to read file contents in PHP 1.fread string fread (int $handle, int $length)Fread () reads up to length bytes from a file pointed to by handle. The function stops reading the file when it has read up to the maximum length of bytes, or
PHP Open File-fopen ()A better way to open a file is through the fopen () function. This function gives you more options than the ReadFile () function.In the course, we will use the text file "Webdictionary.txt":AJAX = asynchronous JavaScript and
File action functions
1, Get filename: basename ();
2, get the file directory: DirName ();
3, PathInfo () Get the file information, return the result is an array, including path, file full name, file name and extension. For example:
How PHP reads files
The file_get_contents () function reads the entire file into a string.
Example
The code is as follows
Copy Code
Echo file_get_contents ("test.txt");?>
Output:
This was a test file with
The completion of the process to achieve the data to save, but encountered a large number of problems, originally intended to use SQLite, but due to storage speed and complexity, or with file implementation.
1. Linux open, read, write these are used
The note study PHP2 a month, the harvest is quite many. But unlike others, I prefer socket.php in the socket. So I decided to write a series of Php-socket reading notes. Have been written from the basic to Socket_raw.
Examples + experience. Examples
Clearerr (clear file stream error flag)
Correlation function feof
Table header file #include
Defines the function void Clearerr (FILE * stream);
The function Description Clearerr () Clears the error flag used by the file stream specified by the
#include
#define N 10
Main ()
{
int exit (int); /*exit () function prototype */
FILE * in, * out;
Char Ch,infile[n],outfile[n];
printf ("Please input infile name:");
scanf ("%s", infile);
ch = getchar (); /* Used to reclaim the last carriage return
C Language File operationsI. Reading and writing of standard documents1. Opening of the fileThe open operation of the fopen () file indicates that the user-specified file will be allocated in memory with a single file structure and a pointer to the
We all know that the PHP GD library can easily create a new image from the URL, GD has Imagecreatefromjpeg (), Imagecreatefrompng () .... And so on function can sometimes read from the URL of the cut BMP images and hateful is GD2 imagecreatefrombmp (
Crawl remote content, has been using the file_get_content function, in fact, already know that there is a curl such a good thing exists, but after a look at the feeling of use is quite complicated, no file_get_content so simple, then the demand is
A simple php file download source code, although does not support the extension of the breakpoint, but can meet some common needs. PHP download file in fact with a tag can be implemented, such as magento-1.8.1.0.zip. But some browsers can recognize
For a php://input introduction, the PHP Official Handbook document has a very clear overview of it.
"Php://input allows to read raw POST data. It is a less memory intensive alternative to $HTTP _raw_post_data and does no need any special php.ini.
A simple php file download source code, although does not support the extension of the breakpoint, but can meet some common needs. PHP download file in fact with a tag can be implemented, such as magento-1.8.1.0.zip. But some browsers can recognize
In the previous article, when extracting SQL statements from the log, I ran into a sentence of SQL that was not extracted across n rows. Later on the web search for two shells:Sed-n '/^insert/,/;/p ' log.sql > Log_insert.sqlSed-n '/^update/,/;/p '
As we all know, the phpGD library can easily create an image from the URL. In GD, imagecreatefromjpeg () and imagecreatefromPNG ()...
We all know that the php GD library can easily create an image from the URL. The GD contains imagecreatefromjpeg (),
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.