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,885 questions

51,811 answers

573 users

How to get the data type of a variable in PHP

9 Answers

0 votes
$n = 10000;

var_dump($n);

 
/*
run:

int(10000) 
 
*/

 



answered Oct 20, 2015 by avibootz
0 votes
$n = 3.14;

var_dump($n);

 
/*
run:

float(3.14) 
 
*/

 



answered Oct 20, 2015 by avibootz
0 votes
$n = "abc";

var_dump($n);

 
/*
run:

string(3) "abc" 
 
*/

 



answered Oct 20, 2015 by avibootz
0 votes
$n = "a";

var_dump($n);

 
/*
run:

string(1) "a" 
 
*/

 



answered Oct 20, 2015 by avibootz
0 votes
$n = 'b';

var_dump($n);

 
/*
run:

string(1) "b" 
 
*/

 



answered Oct 20, 2015 by avibootz
0 votes
$n = null;

var_dump($n);

 
/*
run:

NULL 
 
*/

 



answered Oct 20, 2015 by avibootz
0 votes
$a = true;
var_dump($a);

echo "<br />";

$b = false;
var_dump($b);

 
/*
run:

bool(true)
bool(false) 
 
*/

 



answered Oct 20, 2015 by avibootz
0 votes
$arr = array("C", "Assembler", "PC-MAC");

var_dump($arr);
 
/*
run:

array(3) { [0]=> string(1) "C" [1]=> string(9) "Assembler" [2]=> string(6) "PC-MAC" } 

*/

 



answered Oct 20, 2015 by avibootz
0 votes
class Test 
{
    function F() 
    {
        echo "class Test";
    }
}

$o = new Test();

var_dump($o);
 
/*
run:

object(Test)#1 (0) { } 

*/

 



answered Oct 20, 2015 by avibootz

Related questions

1 answer 138 views
1 answer 99 views
1 answer 79 views
1 answer 70 views
1 answer 85 views
1 answer 84 views
1 answer 199 views
...