$val = $_POST['val'];
$balance = 0;
function test($val, $balance){
if(!preg_match("/^\d+(\.\d+)?$/i",$val) || $val<=0){
return false;
}
if($val>$balance){
return false;
}
return true;
}
var_dump(test($val, $balance));