I have the following problem: The $ re variable does not work for me as I seek to do so. I try to get the variable $ re to obtain the values corresponding to the operation that the user establishes, either by addition, subtraction ... etc.
The errors I missed were that the variable is not defined or has no value, I do not know how to make php recognize the variable and its corresponding content.
Php code:
<?php
if (isset($_POST["n1"]) && isset($_POST["n2"])) {
if ($_POST["op"] == "+") {
return $re = $_POST["n1"] + $_POST["n2"];
}else
if ($_POST["op"] == "-") {
return $re = $_POST["n1"] - $_POST["n2"];
}else
if ($_POST["op"] == "*") {
return $re = $_POST["n1"] * $_POST["n2"];
}else
if ($_POST["op"] == "/") {
return $re = $_POST["n1"] / $_POST["n2"];
}
}
require "views/index.view.php";
and the html code I can not copy it here because instead of showing it, it executes it.