How to use PHP & Fopen(),Fgets() Get Text File Learn how to use the PHP to Get Text File on web server and using function Fopen(),Fgets()
ShotDev Focus:
- PHP & Get Text File (Fopen(),Fgets())
Example
php_get_text_file.php
<html> <head> <title>ShotDev.Com Tutorial</title> </head> <body> <? $strFileName = "shotdev/my.txt"; $objFopen = fopen($strFileName, 'r'); if ($objFopen) { while (!feof($objFopen)) { $file = fgets($objFopen, 4096); echo $file."<br>"; } fclose($objFopen); } ?> </body> </html>
Create a php file and save to path root-path/myphp/
Run
http://localhost/myphp/php_get_text_file.php
Screenshot