Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #3710
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!newsreader4.netcologne.de!news.netcologne.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail |
|---|---|
| Content-Type | text/plain; charset="UTF-8" |
| Message-ID | <5823112.UsPfZmn7uG@PointedEars.de> (permalink) |
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Reply-To | Thomas 'PointedEars' Lahn <php@PointedEars.de> |
| Organization | PointedEars Software (PES) |
| Date | Mon, 07 Nov 2011 23:49:05 +0100 |
| User-Agent | KNode/4.4.11 |
| Content-Transfer-Encoding | 8Bit |
| Subject | Re: PHP Newbie can't evaluate numerical string as number |
| Newsgroups | comp.lang.php |
| References | <A8OdnXgegKYUmyXTnZ2dnUVZ7ridnZ2d@bt.com> |
| Followup-To | comp.lang.php |
| MIME-Version | 1.0 |
| Lines | 24 |
| NNTP-Posting-Date | 07 Nov 2011 23:49:06 CET |
| NNTP-Posting-Host | 2b58250d.newsspool4.arcor-online.net |
| X-Trace | DXC=b5U7eeh`>o]\9P[:DUn00Q4IUK<Cl32<Q4Fo<]lROoRQ8kF<OcfhCO[N7R:9EjSaT_DZm8W4\YJN\;?f@h5gMfb\3koVXd8EHBT1JDSFVk]e3[ |
| X-Complaints-To | usenet-abuse@arcor.de |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.php:3710 |
Followups directed to: comp.lang.php
Show key headers only | View raw
Graham wrote:
> I'm a Perl veteran (well almost!) but a PHP newbie. […]
> <?php
> $formula = "!big_number - !small_number";
> ?>
> […]
> $big_number = 30000;
> $small_number = 3000;
> $formula = str_replace("!", "$", $formula);
> eval("\$formula = \"$formula\";");
You don't want a string, so don't make a string – remove the `\"'.
(I don't think Perl is so much different in that regard.)
> […]
> The above gives me...'formula = 30000 - 3000'
> when of course what I want is...'formula = 27000'
HTH
PointedEars
--
When all you know is jQuery, every problem looks $olvable.
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
PHP Newbie can't evaluate numerical string as number "Graham" <graham.stow@stowassocs.co.uk> - 2011-11-07 16:25 +0000
Re: PHP Newbie can't evaluate numerical string as number The Natural Philosopher <tnp@invalid.invalid> - 2011-11-07 16:56 +0000
Re: PHP Newbie can't evaluate numerical string as number Denis McMahon <denismfmcmahon@gmail.com> - 2011-11-07 17:52 +0000
Re: PHP Newbie can't evaluate numerical string as number "Graham" <graham.stow@stowassocs.co.uk> - 2011-11-08 08:41 +0000
Re: PHP Newbie can't evaluate numerical string as number Erwin Moller <Since_humans_read_this_I_am_spammed_too_much@spamyourself.com> - 2011-11-08 09:56 +0100
Re: PHP Newbie can't evaluate numerical string as number "Graham" <graham.stow@stowassocs.co.uk> - 2011-11-08 09:35 +0000
Re: PHP Newbie can't evaluate numerical string as number Denis McMahon <denismfmcmahon@gmail.com> - 2011-11-08 09:57 +0000
Re: PHP Newbie can't evaluate numerical string as number Tim Streater <timstreater@greenbee.net> - 2011-11-08 10:08 +0000
Re: PHP Newbie can't evaluate numerical string as number Denis McMahon <denismfmcmahon@gmail.com> - 2011-11-08 17:49 +0000
Re: PHP Newbie can't evaluate numerical string as number "Graham" <graham.stow@stowassocs.co.uk> - 2011-11-08 10:27 +0000
Re: PHP Newbie can't evaluate numerical string as number Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-07 23:49 +0100
Re: PHP Newbie can't evaluate numerical string as number Jonathan Stein <jstein@image.dk> - 2011-11-08 11:19 +0100
csiph-web