We help IT Professionals succeed at work.

Php eval() functiona

Qw M
Qw M asked
on
455 Views
Last Modified: 2012-02-10
Hi ,
I have a variable $calc="2*163/100";
I try to use the eval function like this $q=eval($calc); but I recive an error:

"Parse error: parse error in C:\wamp\www\BCRcsm\Man_sablon_price_calculation.php(96) : eval()'d code on line 1"

I need to calculate the string and the  outcome should be 3.26
Please help me!
Comment
Watch Question

Commented:
Why not just do it this way :

<?php

$calc = 2*163/100;
echo "Sum : " . $calc;

?>

Open in new window

Author

Commented:
Because I recive my string variables and the formulas are text.
I need to calculate a string and received a number!

Thank you,
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Thank you!
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.