Rabu, 16 Oktober 2024

Read File In PHP 1

Preparation Step

  1. type this data in editor
    Didi   0458-665-290
    John   07-871-12
    Mary   07-9997-3366
    Steve  03-8174-9123
    Smith  0458-111-113
  2. and save as phonebook.txt. Or you can download file text on phonebook.txt ( box )

Coding Step

  1. type this following PHP code in your PHP editor / web editor:
    <?php
    $filename = 'phonebook.txt';
    if (file_exists($filename)) {
    $fh = fopen($filename,'r');
    if ($fh) {
    while ($line = fgets($fh)) {
    echo($line.'<br/>');
    }
    }
    fclose($fh);
    } else {
    echo "file not exist";
    }
    ?>
  2.  and save as readTextFile1.php. Or you can download file text on readTextFile1.php ( bitbucket )

Bibliography

  • https://daily.dev/
  • https://devdocs.io/
  • https://dev.mysql.com/
  • https://www.php.net/manual/

Related Post

Tidak ada komentar:

Posting Komentar

Various Other Posts