Re: HELP!! how can arithmetic variables(string) ??
| From: | Colin Guthrie | Date: | Thu, 18 Oct 2007 08:45:32 +0000 |
| Subject: | Re: HELP!! how can arithmetic variables(string) ?? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-263283@lists.php.net to get a copy of this message | ||
LKSunny wrote:
> <?
> $a="1+1"; //variables(string)
>
> //how can arithmetic variables(string) ??
> //N ROW................
>
> //output
> echo $a //i need output "2" not "1+1"
> //Please Help, Thank You Very Much !!
> ?>
>
You can do:
eval("echo $a;");
But be warned, this has "Injection Attack" written all over it!
Col