30.05
This commit is contained in:
54
Tematy/T55/T55.5/index.php
Normal file
54
Tematy/T55/T55.5/index.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<!doctype html>
|
||||
<html lang="pl">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>T55.5</title>
|
||||
<link rel="stylesheet" href="../style.css">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>Zadanie T55.5</h1>
|
||||
<h2>Autor: Jakub Grzegorczyk</h2>
|
||||
</header>
|
||||
<div class="box">
|
||||
<p>Napisz funkcję, która na podstawie danych pobranych z tablicy zwracanej przez funkcję getdate() wyświetli bieżącą datę. W dacie miesiąc ma być wyświetlony w postaci tekstu w języku polskim.</p>
|
||||
</div>
|
||||
<div class="box">
|
||||
<?php
|
||||
function getPolishMonth($month): string
|
||||
{
|
||||
$months = [
|
||||
1 => 'styczeń',
|
||||
2 => 'luty',
|
||||
3 => 'marzec',
|
||||
4 => 'kwiecień',
|
||||
5 => 'maj',
|
||||
6 => 'czerwiec',
|
||||
7 => 'lipiec',
|
||||
8 => 'sierpień',
|
||||
9 => 'wrzesień',
|
||||
10 => 'październik',
|
||||
11 => 'listopad',
|
||||
12 => 'grudzień'
|
||||
];
|
||||
return $months[$month];
|
||||
}
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$data = getdate();
|
||||
$dzien = $data['mday'];
|
||||
$miesiac = getPolishMonth($data['mon']);
|
||||
$rok = $data['year'];
|
||||
echo "Bieżąca data to: $dzien $miesiac $rok<br>";
|
||||
echo '<button><a href="index.php">Powrót do formularza</a></button>';
|
||||
} else {
|
||||
echo '<form method="post" action="index.php">
|
||||
<button class="aloneButton" type="submit">Pobierz datę</button>
|
||||
</form>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user