Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="utf-8">
- <title>File</title>
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.css">
- </head>
- <body>
- <div class="container" align="center">
- <?php
- //Первый вариант считывания файла целиком
- $fp = fopen($name="php.txt", "rt") or die("Error!");
- $lines = explode("\n", fread($fp, filesize($name)));
- var_dump($lines);
- $strLines = '';
- foreach($lines as $key => $value){
- $strLines .= $lines[$key];
- }
- echo $strLines;
- fclose($fp);
- //Второй вариант считывания файла целиком
- $str = file_get_contents('php.txt');
- echo '<hr>'.$str.'<hr>';
- //Третий вариант считывания файла блочно
- $fp = fopen($name="php.txt", "rb") or die("Error!");
- $strRead = '';
- while(!feof($fp)){
- $strRead .= fread($fp, 100);
- }
- echo $strRead;
- fclose($fp);
- ?>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement