⊗ppPmFSOC 333 of 447 menu

Combination of File Read and Write Operations in PHP

Reading and writing files can be combined. For example, let's read a file, add an exclamation mark to the end of its text, and write the text back to this file:

$text = file_get_contents('test.txt'); file_put_contents('test.txt', $text . '!');

Suppose you have a file with a certain number written in it. Open this file, square the number, and write it back to the file.

Suppose there is a file count.txt in the root of your site. Initially, it contains the number 0. Make it so that when the page is refreshed, our script increases this number by 1 each time. That is, we will get a page refresh counter in the form of a file.

Suppose there are files 1.txt, 2.txt, and 3.txt in the root of your site. Manually create an array with the names of these files. Iterate through it with a loop, read the contents of each file, merge it into one string, and write it into a new file new.txt. This file should not exist initially.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline