stdq Posted July 19, 2013 Share Posted July 19, 2013 Hi, everyone. So, suppose I have a variable holding a string, like $var = ln(x); I wanna be able to numerically integrate that string - I wanna be able to, inside a for statement, calculate ln(x) for some values of x. How do I make PHP understand the value of the string as a statement? Thanks in advance! Quote Link to comment Share on other sites More sharing options...
stdq Posted July 19, 2013 Author Share Posted July 19, 2013 Nevermind, achieved that using eval. Thanks again! Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted July 19, 2013 Share Posted July 19, 2013 I have no idea what you're trying to do, but eval() is probably not the best way. Quote Link to comment Share on other sites More sharing options...
StefanNET Posted July 25, 2013 Share Posted July 25, 2013 (edited) Use eval() only if you are sure there is no other solution, and only if you are 200% sure your data is safe. Edited July 25, 2013 by StefanNET Quote Link to comment Share on other sites More sharing options...
Ballam Posted August 14, 2013 Share Posted August 14, 2013 Maybe the intval function will assist? it converts variables such as strings into integers. http://php.net/manual/en/function.intval.php Or if you are needing decimals then floatval() http://php.net/manual/en/function.floatval.php Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.