Dynadot โ€” .com Registration $8.99

Why isn't it doing it

Spaceship Spaceship
Watch
Impact
19
hey
i am reading a PHP ebook and it tells me how to change the type of a string..and i m doing what the book says but it keeps saying that the string is A "STRING" rather then a DOUBLE

here is the code
PHP:
define(SPACE, "<br/>");
define (A, " ") ;
$number = 1;
$number2 = "3.14";

print gettype(number2). SPACE;
settype($number2, double);
print gettype(number2). SPACE;

here is wt it displayS:
string
string
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
bool settype ( mixed &var, string type )

Set the type of variable var to type.

Possibles values of type are:
"boolean" (or, since PHP 4.2.0, "bool")
"integer" (or, since PHP 4.2.0, "int")
"float" (only possible since PHP 4.2.0, for older versions use the deprecated variant "double")
"string"
"array"
"object"
"null" (since PHP 4.2.0)

Make it a float? I've never heard of double before.

It also needs quotes.

settype($number2, "float");

Also, I think you need to make it gettype($number2).. you don't have the $.
 
1
•••
Muhahaha
the problem was "$" :p
silly me
and double is a type..its the same as Float....
thanks :D

rep added :D
 
0
•••
Dynadot โ€” .com Registration $8.99Dynadot โ€” .com Registration $8.99
Appraise.net
Unstoppable Domains
Domain Recover
DomainEasy โ€” Live Options
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back