Jump to content

adding string variables


thefollower

Recommended Posts

moreover, that just equals zero.  To get .00045, you need to multiply 45 x .00001 :D

 

 

if you just want to put the two variables together, just make sure there arent two decimal places either.

 

$answer = $multiply.$input;

 

also make sure your variables are all the same case, i.e. $Multiply isn't the same as $multiply

Link to comment
Share on other sites

For starters, they are not strings.

 

php defaults to numeric? If so that is pain in the butt!!!

 

tommyboy.. unfortionutely your idea didn't quite produce what i was hoping for..

 

$Multiply = 0.00;
$Input = 6;

Echo $Answer = $Multiply.$Input;

 

The result gave : 06

Instead of 0.006

 

Hope you can help.

Link to comment
Share on other sites

It defaults to the type of value the variable equals.  If you dont put "quotes" around the number, then it sets to a numeric type.  If you put "quotes" around a number, it sets it to a string.

 

For starters, they are not strings.

 

php defaults to numeric? If so that is pain in the butt!!!

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.