FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » PHP Newbie can't evaluate numerical string as number
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: PHP Newbie can't evaluate numerical string as number [message #175928 is a reply to message #175919] Tue, 08 November 2011 10:19 Go to previous message
Jonathan Stein is currently offline  Jonathan Stein
Messages: 43
Registered: September 2010
Karma:
Member
Den 07-11-2011 17:25, Graham skrev:

> <?php
> $formula = "!big_number - !small_number";
> ?>

function myFormula($big_number, $small_number) {
return $big_number - $small_number;
}

> <?PHP
> include 'vars.php';
> $big_number = 30000;
> $small_number = 3000;
> $formula = str_replace("!", "$", $formula);
> eval("\$formula = \"$formula\";");
> //$formula = intval($formula);
> //settype($formula, "integer");
> print ("formula = $formula\n");
> ?>

include 'vars.php';
print myFormula(30000, 3000);

Regards

Jonathan
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: shiping cart program
Next Topic: he discount UGG boots are best known for its "Classic" sheepskin boots.
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 11:54:03 GMT 2024

Total time taken to generate the page: 0.05549 seconds