Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <DOCTYPE html>
- <html>
- <head><title>Converter</title></head>
- <body>
- <?php
- function celToFah(float $celValueFromForm) : float
- {
- return $celValueFromForm * 1.8 + 32;
- }
- function fahToCel(float $fahValueFromForm) : float
- {
- return ($fahValueFromForm - 32) / 1.8;
- }
- ?>
- <?php
- if (isset($_GET['celName'])) {
- $celValueFromForm = floatval($_GET['celName']);
- $fahValue = celToFah($celValueFromForm);
- $fahMsg = "$celValueFromForm °C = $fahValue °F";
- }
- if (isset($_GET['fahName'])) {
- $fahValueFromForm = floatval($_GET['fahName']);
- $celValue = fahToCel($fahValueFromForm);
- $celMsg = "$fahValueFromForm °F = $celValue °C";
- }
- ?>
- <form>
- Целзии: <input type="number" name="celName">
- <input type="submit" value="Convert">
- <?php
- if (isset($fahMsg)) echo $fahMsg
- ?>
- </form>
- <form>
- Фаренхайт: <input type="number" name="fahName">
- <input type="submit" value="Convert">
- <?php
- if (isset($celMsg)) echo $celMsg
- ?>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement