NameSilo

Why isn't it doing it

SpaceshipSpaceship
SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
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
Close
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
Close
Muhahaha
the problem was "$" :p
silly me
and double is a type..its the same as Float....
thanks :D

rep added :D
 
0
Close
CatchedCatched

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back