Skip to content
Snippets Groups Projects
Commit 6e44c093 authored by Адлан Шамавов's avatar Адлан Шамавов
Browse files

fixes

parents fb346737 62ab1944
No related branches found
No related tags found
1 merge request!8Ptps function 8
This commit is part of merge request !9. Comments created here will be created in the context of that merge request.
<?php
require_once __DIR__ . '/vendor/autoload.php';
$func = new Hp\Test\Functions();
/**
* Переделай своё решение 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("Такого файла не существует.");
}
?>
<!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>
......@@ -77,21 +86,7 @@ $func = new Hp\Test\Functions();
<h1>Function 6</h1>
<?php
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");
readLogFile(__DIR__ . "/files/text.txt");
?>
</body>
</html>
\ No newline at end of file
</html>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment