Re: Thoughts on Feature Request - Arithmetic
| From: | Robert Cummings | Date: | Fri, 07 Dec 2007 16:23:45 +0000 |
| Subject: | Re: Thoughts on Feature Request - Arithmetic | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-33838@lists.php.net to get a copy of this message | ||
On Fri, 2007-12-07 at 16:44 +0100, Derick Rethans wrote:
> On Fri, 7 Dec 2007, Nathan Rixham wrote:
>
> > In-Built PHP Functions for parsing of basic arithmetic and if possible
> > fraction to decimal and decimal to fraction
> >
> > $arithmetic_string = "3*5";
> > echo arith($arithmetic_string); // returns float 15
>
> What's wrong with eval?
>
> <?php
> eval( '$res = 3 * 5;' );
> echo $res, "\n";
Maybe it's from user input? And it is generally taught that if eval() is
the solution then you're on the wrong track.
Cheers,
Rob.
--
...........................................................
SwarmBuy.com - http://www.swarmbuy.com
Leveraging the buying power of the masses!
...........................................................