Reading from a file
<?php
    $file 
fopen("sample.txt""r");
    while (!
feof($file)) {
        echo 
fgets($file), "<BR>";
    }
?>
Reading from a URL
<?php $file fopen("http://www.php.net/file.txt""r"); ?>
Writing to a file
<?php
    $file 
fopen("agent.log""a");
    
fputs($file$HTTP_USER_AGENT."\n");
?>