Skip to content

Instantly share code, notes, and snippets.

@pchatterjee
Last active October 3, 2019 23:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pchatterjee/def8adbf6a12a18211aaa84299426f5b to your computer and use it in GitHub Desktop.
Save pchatterjee/def8adbf6a12a18211aaa84299426f5b to your computer and use it in GitHub Desktop.
// function to calculate and return result
function calc($x, $y, $op) {
if ($op == '/' && $y == 0) {
$prod = "&#8734";
}
else {
// build up the expression
$exp = "$x"."$op"."$y";
// evaluate it
eval("\$prod=$exp;");
}
// return the result
return $prod;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment