Re: PHP Newbie can't evaluate numerical string as number [message #175929 is a reply to message #175926] |
Tue, 08 November 2011 10:27 |
Graham
Messages: 4 Registered: November 2011
Karma:
|
Junior Member |
|
|
"Denis McMahon" <denismfmcmahon(at)gmail(dot)com> wrote in message
news:4eb8fcf9$0$28445$a8266bb1(at)newsreader(dot)readnews(dot)com...
> On Tue, 08 Nov 2011 09:35:02 +0000, Graham wrote:
>
>> Yes it works! (although I admit I'm not entirely sure why). Many thanks!
>> And apologies to Denis for having doubted him.
>
> Heads up - we don't top post in newsgroups. Reply goes at the bottom so
> that reading naturally down the page response is after the comment it
> applies to.
>
> If you read the php manual for eval http://uk.php.net/manual/en/
> function.eval.php , all is explained:
>
> There are two ways to get a value from eval into the script that calls
> eval:
>
> a) use return inside the eval code, and assign the value of eval to a
> variable, viz:
>
> $evalResult = eval("return $big_number - $small_number;");
> echo $evalResult;
>
> b) assign the result to a variable inside the eval code:
>
> eval("$evalResult = $big_number - $small_number;");
> echo $evalResult;
>
> These are the two methods I attempted to show in my example.
>
> Rgds
>
> Denis McMahon
I hang my head in shame! Thinking about it, i've been critised for top
posting before, but couldn't remember the drill as I post to newsgroups so
rarely. Thanks for being patient and polite (unlike some). And thanks for
the very thorough explanation which I now follow.
R's
Graham Stow
|
|
|