PHP File Handling - php test - Phptpoint.com

PHP File Handling

Best PHP Training with Live Project in Noida Fee is only 7500/-Click here for FREE DEMO.

/ins>

PHP File Handling(file system)

The file system functions allow you to access and manipulate the file.

file system provides a concept to start a specific data using different types of file format.

That means file gives us linear type database concept. There is no any type of relations will be found with value because it doesn’t support RDBMS concept.

Through this concept you will retrieved data from disk files, XML documents and many other data sources.

Files In a computer, a file system (sometimes written filesystem) is the way in which files are named and where they are placed logically for storage and retrieval.

The DOS, Windows, OS/2, Macintosh, and UNIX-based operating systems all have file systems in which files are placed somewhere in a hierarchical (tree) structure.

A file is placed in a directory (folder in Windows) or sub-directory at the desired place in the tree structure.

How to Create a file using PHP

touch( ) function is used to create a file

Syntax

Eg

Output
Check your folder manually
(same folder where you have saved your program) a file will be created


How to Delete a file using PHP

unlink( ) function is used to delete a file

Syntax

Eg

Output
Check your folder manually
(same folder where you have saved your program) a file will be deleted


How to copy a file using PHP

copy( ) function is used to copy file
Syntax

Eg

Output
Check your folder manually
(same folder where you have saved your program) a file will be copied with new name

How to Rename file using PHP

rename( ) function is used to rename file.
Syntax

Eg

Output
Check your folder manually
(same folder where you have saved your program) a file will be renamed

Checks whether a file or directory exists

file_exists( ) function is used to check file or directory existence.
Syntax

Eg

Output
It returns true(1) if file exists
otherwise return false(blank screen)


Check size of the file in PHP

filesize( ) function is used to check file size.
Syntax

Eg

Output
0 Bytes

Check Path of the file in PHP

realpath( ) function is used to check real path of the file.
Syntax

Eg

Output
C:xampplitehtdocsYoufProjectfileName with extension
//OR
C:wampwwwYoufProjectfileName with extension

Keep Updating yourself