Re: Force variables to add
| From: | Martin A. Marques | Date: | Mon, 08 Jan 2001 19:36:17 +0000 |
| Subject: | Re: Force variables to add | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-33289@lists.php.net to get a copy of this message | ||
El Sáb 08 Ene 2000 16:37, Brandon Orther escribió:
> I have 2 variables, and I want them to add with each other. But all I get
> is the first variable and then the second variable. Here is and example:
>
> ------------------------
> $var1 = "2";
> $var2 = "3";
>
> $var3 = $var1 + $var2;
>
> echo "$var3";
>
> OUTPUT = 23
> ------------------------
>
> Does anyone know how I can forces them to add?
The problem here is that you are giving char "2" and char "3" to the
variables $var1 and $var2. Take the doble quotes away and it should work.
P.D.: I didn't know that the + applied to two chars concatenated them.
Saludos... :-)
--
System Administration: It's a dirty job,
but someone told I had to do it.
-----------------------------------------------------------------
Martín Marqués email: martin@math.unl.edu.ar
Santa Fe - Argentina http://math.unl.edu.ar/~martin/
Administrador de sistemas en math.unl.edu.ar
-----------------------------------------------------------------