这是我在索引文件中写的
<?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);
功能
doMathsA
看起来像
<?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";