Jump to content

Change variable type


chiprivers

Recommended Posts

Is it possible to change the type that a variable is being stored as?

 

I have a var which is behaving like a string but contains a number.  I am assuming that it is behaving like a string due to the way that its value is extracted and applied to the var.

 

Below is an example to demonstrate what I mean by behaving like a string:

var x = 10000;
var y = 999;

var z = x + y;

 

In my script, the above value for z is displaying as 10000999 when I want it to be adding the values so should be 10999.

 

Is there a way that once a var has a value applied, if it is stored as a string, I can change it to be numerical?

Link to comment
https://forums.phpfreaks.com/topic/211164-change-variable-type/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.