Go Back   CP Web Hosting - reseller hosting > Server Scripting > PHP
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-21-2007, 12:23 PM
Junior Member
 
Join Date: May 2007
Posts: 19
Default Variable type

Apart from the getype() function in PHP, is there any more function, which can also return the variable type.
Reply With Quote
  #2 (permalink)  
Old 06-21-2007, 12:27 PM
Junior Member
 
Join Date: Apr 2007
Posts: 5
Default

gettype() is a specialized tool. It does what it promises and returns a variable's type.
var_dump() also tells you a variable's type with that it also tells you contents it is holding. More than that, for complex types such as arrays and objects, var_dump() provides information about all the types contained within the variable, as well as about the variable itself.

$test = 5;
var_dump( $test );


This fragment gives us the following result:

int(5)


This tells us that the variable $test contains an integer and that the value of that integer is 5.

With var_dump() we did not need print to print the the result because the function prints its findings directly to the browser or command line.

but, with the gettype(), we do need to use the print statement:
print gettype(test);
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 03:29 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0