Function for simple math doesn’t work what am I doing wrong? [on hold]

This is what I wrote in the index file

<?php
echo “Please enter your first number?n”;

$first = stream_get_line(STDIN, 100, “n”);

echo “Please enter /, +, * or /?n”;

$operator = stream_get_line(STDIN, 100, “n”);

echo “Please enter your second number?n”;

$second = stream_get_line(STDIN, 100, “n”);

include_once “library/maths/mathsA.php”;

echo doMathsA ($first, $operator, $second);

The function doMathsA looks like

<?php
function doMathsA ($first, $operator, $second){

switch ($operator)

{
case ‘+’;
$result=$first+$second;
break;

case ‘*’;
$result=$first*$second;
break;

case ‘/’;
$result=$first/$second;
break;

case ‘-‘;
$result=$first-$second;
break;
}}

echo “Your result is $result”;

Read more here:: Function for simple math doesn’t work what am I doing wrong? [on hold]

Leave a Reply

Your email address will not be published. Required fields are marked *