Commit 754559a0 authored by Адлан Шамавов's avatar Адлан Шамавов
Browse files

fixes2

parent 6e44c093
Loading
Loading
Loading
Loading
+27 −22
Original line number Diff line number Diff line
<?php
/** 
 * Переделай своё решение 8 задачи:
 * замени вывод всего текста из файла разом на 
 * построчный вывод используя yield 
 * @param string $filePath путь до файла
 * @return void  
 */  
function readLogFile(string $filePath): void {
    if (file_exists($filePath)) {
        $text = "";
        $file = fopen($filePath, "r");
        while(!feof($file)) {
            $line = fgets($file);
            $text .= $line;
        }
        fclose($file);
        print($text);
    }
    else print("Такого файла не существует.");
}

require_once __DIR__ . '/vendor/autoload.php';

$func = new Hp\Test\Functions();

?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h1>Function 1</h1>
@@ -86,7 +77,21 @@ function readLogFile(string $filePath): void {

    <h1>Function 6</h1>
    <?php
        readLogFile(__DIR__ . "/files/text.txt");
        print("<h2>Пятницы 13: </h2>");
        foreach($func->countFriday13(2024) as $date) {
            print($date->format("Y-m-d l") . "\n");
        }
    ?>

    <h1>Function 7</h1>
    <?php
        print("<h2>Разница дней: </h2>");
        print($func->diffDays(new DateTimeImmutable(), new DateTimeImmutable("2025-01-01")));
    ?>

    <h1>Function 8</h1>
    <?php
        $func->readLogFile(__DIR__ . "/public/text.txt");
    ?>
</body>
</html>
 No newline at end of file