Ho trovato questa funzione, che sembrava all'inizio non funzionare se facevo tipo 5+3/2 se invece faccio (5+3)*(3+4)/2 funzione , ha un unico problema :
Codice PHP:
<?php if (isset($_POST['espressione'])){ function calculate_string( $mathString ) { $mathString = trim($mathString); // trim white spaces $mathString = ereg_replace ('[^0-9\+-\*\/\(\) ]', '', $mathString);//remove any non-numbers chars; exception for math operators $compute = create_function("", "return (" . $mathString . ");" ); return 0 + $compute(); } $string = $_POST['espressione']; echo calculate_string($string); } ?>
il risultato me lo da ma da questo tipo di errore :
Deprecated: Function ereg_replace() is deprecated in /var/www/vhosts/freestyleweb.it/easysoftware.biz/calcolatrice.php on line 14 7
corrisondente
Codice PHP:
$mathString = ereg_replace ('[^0-9\+-\*\/\(\) ]', '', $mathString);//remove any non-numbers chars; exception for math operators
voi che dite? può andare e come posso togliere qusto errore?