Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,859 questions

51,780 answers

573 users

How to get the integer value of a variable (float) in PHP

5 Answers

0 votes
/*
int intval ( mixed $var [, int $base = 10 ] )
*/

echo intval(3.14) . "<br />";
    
/*
run:

3

*/

 



answered Dec 13, 2015 by avibootz
0 votes
/*
int intval ( mixed $var [, int $base = 10 ] )
*/

echo intval(500) . "<br />";
    
/*
run:

500

*/

 



answered Dec 13, 2015 by avibootz
0 votes
/*
int intval ( mixed $var [, int $base = 10 ] )
*/

echo intval(+100) . "<br />";
echo intval(-100) . "<br />";
    
/*
run:

100
-100

*/

 



answered Dec 13, 2015 by avibootz
0 votes
/*
int intval ( mixed $var [, int $base = 10 ] )
*/

echo intval(010) . " - 010 octal = 8 decimal <br />";
echo intval('010') . "<br />";
    
/*
run:

8 - 010 octal = 8 decimal 
10

*/

 



answered Dec 13, 2015 by avibootz
edited Dec 13, 2015 by avibootz
0 votes
/*
int intval ( mixed $var [, int $base = 10 ] )
*/

echo intval(0x1A1) . " - 0x1A1 HEX = 417 decimal <br />";
echo intval('0x1A1') . "<br />";
    
/*
run:

417 - 0x1A1 HEX = 417 decimal 
0

*/

 



answered Dec 13, 2015 by avibootz

Related questions

2 answers 159 views
1 answer 150 views
2 answers 239 views
1 answer 201 views
4 answers 299 views
1 answer 194 views
...