15,076
edits
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
Print type of the variable | Print type of the variable | ||
* PHP: {{kbd | key=<nowiki>echo "type of variable: " . gettype($var);</nowiki>}}<ref>[http://php.net/manual/en/function.gettype.php PHP: gettype - Manual]</ref> | * PHP gettype(): {{kbd | key=<nowiki>echo "type of variable: " . gettype($var);</nowiki>}}<ref>[http://php.net/manual/en/function.gettype.php PHP: gettype - Manual]</ref> | ||
* Python | * Python type():<ref>[https://docs.python.org/3.6/library/functions.html?highlight=type#type type]</ref><ref>[https://waoewaoe.wordpress.com/2009/05/18/type-cast-variable-to-string-in-python/ Type cast variable to String in python | Ploy's Blog | A Blog About Techinical Stuff]</ref> or {{kbd | key=<nowiki>print(type(var))</nowiki>}} | ||
<pre> | <pre> | ||
type(var) # return <class 'type'> | type(var) # return <class 'type'> | ||
print(type(var)) | print(type(var)) | ||
print("type of variable: " + str(type(var))) # cast type to string | print("type of variable: " + str(type(var))) # python v. 3 cast type to string | ||
</pre> | |||
* Javascript typeof()<ref>[https://www.w3resource.com/javascript/operators/typeof.php JavaScript : typeof operator - w3resource]</ref> | |||
<pre> | |||
typeof var | |||
console.log("type of variable:: " + typeof var) | |||
</pre> | </pre> | ||
* R: [https://stat.ethz.ch/R-manual/R-devel/library/base/html/typeof.html typeof()] | * R: [https://stat.ethz.ch/R-manual/R-devel/library/base/html/typeof.html typeof()] | ||