Preparation Step
- 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 - and save as phonebook.txt. Or you can download file text on phonebook.txt ( box )
Coding Step
- 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";
}
?> - and save as readTextFile1.php. Or you can download the source code file on readTextFile1.php ( bitbucket )
Running Step
- Running your PHP Web Server, such as XAMPP. If you want to learn how to start XAMPP, click Hello World PHP XAMPP.
- Open your Internet Browser.
- Type your local host address, such as http://localhost/readTextFile1.php.
- Press Enter.
- Then you can see the result in browser.
<< back to Study About PHP 1
Bibliography
- https://daily.dev/
- https://devdocs.io/
- https://dev.mysql.com/ ( manual ebook )
- https://www.php.net/manual/ ( manual ebook )
Tidak ada komentar:
Posting Komentar