I'm trying to calculate dynamic formula value for dynamic inputs, that is user inputs and formulla all will be given by user, i tried in php, but failed , codes as follows,
then i used java script to that formula calculation, it works quite, but it return string output so that i can't use that for further calculation, or i need to use java script whole project, its very difficult,
and not even can not convert the output as integer, if convert its value only zero, java script used code as follows,
so, requesting all to solve the prob in php with out-using javascript,
or how to conver the value as pure-integer,
Expecting sollution asap.
Thanks
Code:
$a=10; //$a - integer value user input - dynamic
$b=20; //$b - integer value user input - dynamic
echo $formulla1= ('$a+$b+11'); // formulla so, string value - user input - dynamic
// out put is $a+$b+11... we need to show - 41
echo "<br>";
echo $formulla2 = "$a+$b"; // formulla so, string value - user input - dynamic
// out put is 10+20... we need to show - 30
and not even can not convert the output as integer, if convert its value only zero, java script used code as follows,
Code:
echo "<br>"; echo $formulla3= "<script type=\"text/javascript\">"."document.write(j=eval ($formulla2));"."</script>"; //output is 30 echo "<br>"; echo gettype ($formulla3); // now $formulla3 is a string
or how to conver the value as pure-integer,
Expecting sollution asap.
Thanks
Comment