Get the App
SLTechnology News&Howtos  ›  Development  › 

What are the file manipulation functions in PHP

Shulou Source: shulou.com Published: 2022-06-01 02:55:54 10月05日 Update

This article will explain in detail what are the file manipulation functions in PHP. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.

File operation function

Opendir (path): open a path resource (read all data inside the path into memory)

Readdir (path resource): reads the name of the file pointed to by the current resource pointer from the folder resource, and the pointer moves down one bit.

Closedir (resources): release the corresponding file resources

Scandir (path): reads all the file names within a path and returns an array. Each element of the array is a file name.

File_exists: determine whether a file exists (in a broad sense: path and file)

Is_dir: determines whether a specified path exists (folder)

Is_file: determines whether a specified path is a file (file)

Mkdir: create a path that will report an error if it exists

Rmdir: removing folder

File_get_contents: reads the data contents from a specified file.

File_put_contents: writes the specified string to the corresponding file

Fopen: open a file resource

Fgetc:c stands for character, reading one character at a time

Fgets:s stands for string, which means that multiple characters can be read, depending on the specified read length or whether a newline is encountered (a maximum of one row of data can be read)

Both functions operate on the current resource pointer, and both move the pointer down after reading

Fread: gets the specified length of data until the end of the file

Fwrite: writes data to the location of the file resource pointer. Writing will not move back what already exists in the current location, but will overwrite it.

Fseek: assign the pointer to the corresponding location

Fclose: use the corresponding file resources

Copy: copyin

Unlink: deleting fil

Rename: renaming fil

Filemtime:m stands for modify, and the last time the file was modified

Filesize: file size (bytes)

Fileperms: file permissions (octal under Linux)

What language is php php, a nested acronym, is the abbreviation of English Hypertext preprocessing language (PHP:Hypertext Preprocessor). PHP is a kind of HTML embedded language. PHP is somewhat similar to Microsoft's ASP. It is a scripting language that embeds HTML documents on the server. The style of the language is similar to C language, and now it is widely used by many website programmers.

About "what are the file manipulation functions in PHP" this article is shared here, I hope the above content can be of some help to you, so that you can learn more knowledge, if you think the article is good, please share it out for more people to see.

Tags: Files paths resources pointers languages data functions representatives locations characters folders articles things content arrays file names more abbreviations length good Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux OPPO Reno Microsoft Apple Shulou Information