PHP File Handling
What is the File Handling in php
The term "file handling" refers to a group of procedures in PHP that enable read/write operations on disk files using PHP code. In PHP, a file is a resource object, from which data may be read or written to in a linear way.
create a file
" filehandling.txt" , stored the server data.
web desingning free of cost
learn programming language =webdesigningtheory.blogspot.com
ஃ PHP Open file-fopen()
Example :-
<?php
$file = fopen(" filehandling.txt","r");
?>
OUTPut :-
web desingning free of cost
learn programming language =webdesigningtheory.blogspot.com
ஃPHP Close File- fclose()
PHP fclose() function use close open file pointer.
Syntax :-
fclose(resource $handle)
Example :-
<?php
fclose($handle);
?>
ஃ PHP Read File - fread()
PHP fread() function use to read content file. accept two argument.
Example :-
<?php
$file = fopen("filehandling.txt","r");
$content = fread($file,filesize(filehandling.txt"));
echo $content;
fclose($file);
?>
ஃ PHP Write File - fwrite()
Example :-
<?php
$file = fopen("filehandling.txt","w");
fwrite($file, "This is a test.");
fclose($file);
?>
ஃ PHP Delete File- unlink()
Example :-
<?php
unlink ("data.txt");
echo "file delete";
?>
Related Post :-
Post a Comment