We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
[php] adding variables; me... again
Topic Started: Feb 17 2005, 08:28 PM (346 Views)
mathiaus
Member Avatar
mathiaus maximus™
[ *  *  *  *  *  * ]
me again sorry.

right then. I have set the value of some variables and am trying to add them together but I can't get it to work.

$subtotal = "$Q1+$Q2+$Q3";
echo $subtotal;

all this does is print the values seperately withn the sign. :no:


Any ideas?
Thanks again
Offline Profile Quote Post Goto Top
 
eXaulz
GU˛ Services; Support Manager
[ *  * ]
Of course.. Do this:

Code:
 

<?php

$subtotal = $Q1 + $Q2 + $Q3;

echo $subtotal;

?>


(You don't do math around quotes, my friend.)
Offline Profile Quote Post Goto Top
 
SkItZo
Support Volunteer
[ *  *  * ]
If you also want a fly-by tutorial on arithmethic operators for PHP, then visit this link

http://chandan.tx.com.ru/tutorials/phptuts/tut2.html
Offline Profile Quote Post Goto Top
 
mathiaus
Member Avatar
mathiaus maximus™
[ *  *  *  *  *  * ]
Thank you!!

eXaulz > I never thought of spaces or removing the quotes

SKITZo > I have seen pages about difefrent operators but they didnt use variables and I got confused.

Thanks both of you
Matt
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Technology Chat · Next Topic »
Add Reply