These tips will help you very much in the first steps working with PHP, at least in file processing.
Create a File
$my_file = 'file.txt';
$handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file); //implicitly creates file
Open a File
$my_file = 'file.txt';
$handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file); //open file for writing ('w','r','a')...
Read a File
$my_file = 'file.txt';
$handle = fopen($my_file, 'r');
$data = fread($handle,filesize($my_file));
Write to a File
$my_file = 'file.txt';
$handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file);
$data = 'This is the data';
fwrite($handle, $data);
Append to a File
$my_file = 'file.txt';
$handle = fopen($my_file, 'a') or die('Cannot open file: '.$my_file);
$data = 'New data line 1';
fwrite($handle, $data);
$new_data = "\n".'New data line 2';
fwrite($handle, $new_data);
Close a File
$my_file = 'file.txt';
$handle = fopen($my_file, 'w') or die('Cannot open file: '.$my_file);
//write some data here
fclose($handle);
Delete a File
$my_file = 'file.txt';
unlink($my_file);View more threads in the same category:
- Wiculty’s DevOps Certification Training Course in Jayanagar Bangalore
- Wiculty’s DevOps Certification Training Course in Jayanagar
- buy a USA/UK passport online( https://legitcleandocs.com)visa, SNN, id card
- buy registered drivers license (legitcleandocs.com)IELTS, id
- Buy Passport,Driver License,Age & ID Card,(Whatsapp:.......: +1 (551) 239-2904) Visas
- Buy Passport,Driver License,Age & ID Card,(Whatsapp:.......: +1 (551) 239-2904) Visas
- Buy Passport,Driver License,Age & ID Card,Visas and Undetected Counterfeit Money. Ema
- buy real drivers license(https://legitcleandocs.com)buy Austria id card, passports
- BUY DRIVER'S LICENSE ONLINE https://worldpassporte.com/
- Buy Passport,Driver License,Age & ID Card,(Whatsapp:.......: +1 (551) 239-2904) Visas
Bookmarks