Print variable types: Difference between revisions

From LemonWiki共筆
Jump to navigation Jump to search
(Created page with "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 -...")
 
No edit summary
Line 2: Line 2:


* 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: {{kbd | key=<nowiki>echo "type of variable: " . gettype($var);</nowiki>}}<ref>[http://php.net/manual/en/function.gettype.php PHP: gettype - Manual]</ref>
* Python v. 3: {{kbd | key=<nowiki>print("type of variable: " + str(type(var)))</nowiki>}}<ref>[https://docs.python.org/3.6/library/functions.html?highlight=type#type type]</ref>
* Python v. 3:<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>
type(var) # return <class 'type'>
print(type(var))
print("type of variable: " + str(type(var))) # cast type to string
</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()]



Revision as of 15:33, 31 December 2017