$S = new Calc(); $S->setOperation('5 - 5'); $S->run(); $S->getResult(); if ($S->getResult() == 0) { echo "Test subtraction 5 - 5 passed with result 0\n"; } // multiply $M = new Calc(); $M->setOperation('5 * 5'); $M->run(); if ($M->getResult() == 25) { echo "Test subtraction 5 * 5 passed with result 25\n"; } // divide $D = new Calc(); $D->setOperation('5 / 5'); $D->run(); if ($D->getResult() == 1) { echo "Test subtraction 5 / 5 passed with result 1\n"; } // all the things $X = new Calc(); $X->setOperation('5 * 5 - 4 / 2 + 7'); $X->run(); if ($X->getResult() == 30) { echo "Test 5 * 5 - 4 / 2 + 7 passed with result 30\n"; } echo 'Running 5 * 5 - 4 / 2 + 7 as a static method Calc::exec() ..... returning: '; echo Calc::exec('5 * 5 - 4 / 2 + 7'); echo "\n";