Correction
This commit is contained in:
parent
7eb62d14ef
commit
62edb91f95
4 changed files with 75 additions and 60 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
<?php
|
||||||
|
if (isset($_GET["nb"])) {
|
||||||
|
$nb = (int)$_GET["nb"];
|
||||||
|
if ($nb < 0 and $nb > 100)
|
||||||
|
$nb = null;
|
||||||
|
} else
|
||||||
|
$nb = null;
|
||||||
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
|
@ -7,9 +16,7 @@
|
||||||
<body>
|
<body>
|
||||||
<ul>
|
<ul>
|
||||||
<?php
|
<?php
|
||||||
if (isset($_GET["nb"])) {
|
if ($nb !== null) {
|
||||||
$nb = (int) $_GET["nb"];
|
|
||||||
if ($nb >= 0 and $nb <= 100)
|
|
||||||
for ($i = 0; $i < $nb; $i++) { ?>
|
for ($i = 0; $i < $nb; $i++) { ?>
|
||||||
<li>Hello World !</li>
|
<li>Hello World !</li>
|
||||||
<?php }
|
<?php }
|
||||||
|
|
|
@ -1,3 +1,18 @@
|
||||||
|
<?php
|
||||||
|
$nb = null;
|
||||||
|
$name = null;
|
||||||
|
$error = false;
|
||||||
|
if (isset($_GET["nb"]) AND isset($_GET["name"])) {
|
||||||
|
$nb = (int)$_GET["nb"];
|
||||||
|
$name = htmlspecialchars($_GET["name"]);
|
||||||
|
if ($nb < 0 or $nb > 100) {
|
||||||
|
$error = true;
|
||||||
|
$nb = null;
|
||||||
|
$name = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
|
@ -5,14 +20,6 @@
|
||||||
<title>Hello World 3</title>
|
<title>Hello World 3</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php
|
|
||||||
$nb = 0;
|
|
||||||
$name = "";
|
|
||||||
if (isset($_GET["nb"]) AND isset($_GET["name"])) {
|
|
||||||
$nb = (int)$_GET["nb"];
|
|
||||||
$name = htmlspecialchars($_GET["name"]);
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<form>
|
<form>
|
||||||
<label for="nb">Number: </label>
|
<label for="nb">Number: </label>
|
||||||
<input id="nb" type="number" name="nb" min="0" max="100" value="<?= $nb ?>" required>
|
<input id="nb" type="number" name="nb" min="0" max="100" value="<?= $nb ?>" required>
|
||||||
|
@ -21,17 +28,17 @@
|
||||||
<input type="submit" value="Send">
|
<input type="submit" value="Send">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<ul>
|
|
||||||
<?php
|
<?php
|
||||||
if ($nb AND $name) {
|
if ($error) { ?>
|
||||||
if ($nb >= 0 and $nb <= 100)
|
<strong>Invalid args !</strong>
|
||||||
|
<?php } ?>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<?php if ($nb !== null AND $name !== null) {
|
||||||
for ($i = 0; $i < $nb; $i++) { ?>
|
for ($i = 0; $i < $nb; $i++) { ?>
|
||||||
<li>Hello <?= $name ?> !</li>
|
<li>Hello <?= $name ?> !</li>
|
||||||
<?php }
|
<?php }
|
||||||
else { ?>
|
}?>
|
||||||
<strong>Invalid args !</strong>
|
|
||||||
<?php }
|
|
||||||
} ?>
|
|
||||||
</ul>
|
</ul>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -1,3 +1,39 @@
|
||||||
|
<?php
|
||||||
|
$children = 0;
|
||||||
|
$married = false;
|
||||||
|
$income = 0;
|
||||||
|
if (isset($_POST["children"]) AND isset($_POST["income"])) {
|
||||||
|
$children = (int)$_POST["children"];
|
||||||
|
if (isset($_POST["married"]))
|
||||||
|
$married = (bool)$_POST["married"];
|
||||||
|
else
|
||||||
|
$married = false;
|
||||||
|
$income = (float)$_POST["income"];
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($married)
|
||||||
|
$n = 2+$children/2;
|
||||||
|
else
|
||||||
|
$n = 1+$children/2;
|
||||||
|
|
||||||
|
$q = $income/$n;
|
||||||
|
|
||||||
|
$t = 0;
|
||||||
|
if ($q >= 0 AND $q <= 9963)
|
||||||
|
$t = $income*0 - 0*$n;
|
||||||
|
elseif ($q <= 27518)
|
||||||
|
$t = $income*0.14 - 1394.96*$n;
|
||||||
|
elseif ($q <= 73778)
|
||||||
|
$t = $income*0.3 - 5798*$n;
|
||||||
|
elseif ($q <= 156243)
|
||||||
|
$t = $income*0.41 - 13913.69*$n;
|
||||||
|
elseif ($q >= 156244)
|
||||||
|
$t = $income*0.45 - 20163.45*$n;
|
||||||
|
|
||||||
|
$t = round($t);
|
||||||
|
echo $q;
|
||||||
|
?>
|
||||||
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
|
@ -5,20 +41,7 @@
|
||||||
<title>Hello World 4</title>
|
<title>Hello World 4</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php
|
<form method="POST">
|
||||||
$children = 0;
|
|
||||||
$married = false;
|
|
||||||
$income = 0;
|
|
||||||
if (isset($_GET["children"]) AND isset($_GET["income"])) {
|
|
||||||
$children = (int)$_GET["children"];
|
|
||||||
if (isset($_GET["married"]))
|
|
||||||
$married = (bool)$_GET["married"];
|
|
||||||
else
|
|
||||||
$married = false;
|
|
||||||
$income = (float)$_GET["income"];
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
<form>
|
|
||||||
<label for="children">Number of children: </label>
|
<label for="children">Number of children: </label>
|
||||||
<input id="children" type="number" name="children" min="0" value="<?= $children ?>" required> <br />
|
<input id="children" type="number" name="children" min="0" value="<?= $children ?>" required> <br />
|
||||||
<label for="married">Married: </label>
|
<label for="married">Married: </label>
|
||||||
|
@ -27,29 +50,7 @@
|
||||||
<input id="income" type="number" name="income" min="0" step="any" value="<?= $income ?>" required> <br />
|
<input id="income" type="number" name="income" min="0" step="any" value="<?= $income ?>" required> <br />
|
||||||
<input type="submit" value="Send">
|
<input type="submit" value="Send">
|
||||||
</form>
|
</form>
|
||||||
<?php
|
|
||||||
if ($married)
|
|
||||||
$n = 2+$children/2;
|
|
||||||
else
|
|
||||||
$n = 1+$children/2;
|
|
||||||
|
|
||||||
$q = $income/$n;
|
|
||||||
|
|
||||||
$t = 0;
|
|
||||||
if ($q >= 0 AND $q <= 9963)
|
|
||||||
$t = $income*0 - 0*$n;
|
|
||||||
elseif ($q >= 9964 AND $q <= 27518)
|
|
||||||
$t = $income*0.14 - 1394.96*$n;
|
|
||||||
elseif ($q >= 27519 AND $q <= 73778)
|
|
||||||
$t = $income*0.3 - 5798*$n;
|
|
||||||
elseif ($q >= 73779 AND $q <= 156243)
|
|
||||||
$t = $income*0.41 - 13913.69*$n;
|
|
||||||
elseif ($q >= 156244)
|
|
||||||
$t = $income*0.45 - 20163.45*$n;
|
|
||||||
|
|
||||||
$t = round($t);
|
|
||||||
|
|
||||||
?>
|
|
||||||
<p>Your taxes is <?= $t ?></p>
|
<p>Your taxes is <?= $t ?></p>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Reference in a new issue