3v4l.org

run code in 300+ PHP versions simultaneously
<?php function loancalc() { $result = '0.00'; /** testing **/ $_POST['submit'] = true; $_POST['principal'] = "7500.50"; $_POST['interest'] = "0.22"; $_POST['tenure'] = "7.7"; /** end testing **/ if( isset( $_POST['submit'] )){ // inspecting submitted values so that... foreach ($_POST as $key => $value) { $bool[$key] = ctype_print( $value ); } // ... if proven valid, then make assignments if ( $bool['principal'] && $bool['interest'] && $bool['tenure'] ) { [$principal, $interestRate,$tenure] = [$_POST['principal'], $_POST['interest'], $_POST['tenure']]; $result = $principal * $interestRate * $tenure; } echo number_format( $result,2,'.',',' ); // default English representation } // if posted ... }// end func loancalc();

preferences:
30.63 ms | 405 KiB | 5 Q