Print variable types: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
| Line 1: | Line 1: | ||
Print type of the variable | Print type of the variable | ||
PHP gettype()<ref>[http://php.net/manual/en/function.gettype.php PHP: gettype - Manual]</ref>: | |||
<pre> | <pre> | ||
# define the variable | # define the variable | ||
| Line 9: | Line 9: | ||
echo "type of variable: " . gettype($var); | echo "type of variable: " . gettype($var); | ||
</pre> | </pre> | ||
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> | ||
# define the variable | # define the variable | ||
| Line 19: | Line 20: | ||
print("type of variable: " + str(type(var))) # python v. 3 cast type to string | print("type of variable: " + str(type(var))) # python v. 3 cast type to string | ||
</pre> | </pre> | ||
Javascript typeof()<ref>[https://www.w3resource.com/javascript/operators/typeof.php JavaScript : typeof operator - w3resource]</ref> | |||
<pre> | <pre> | ||
# define the variable | # define the variable | ||
| Line 28: | Line 30: | ||
console.log("type of variable:: " + typeof a); | console.log("type of variable:: " + typeof a); | ||
</pre> | </pre> | ||
R: [https://stat.ethz.ch/R-manual/R-devel/library/base/html/typeof.html typeof()] | |||
== references == | == references == | ||
Revision as of 14:42, 2 January 2018
Print type of the variable
PHP gettype()[1]:
# define the variable $var = 3.14159; # print type of the variable echo "type of variable: " . gettype($var);
Python type():[2][3] or print(type(var))
# define the variable
var = 3.14159
# print type of the variable
type(var) # return <class 'type'>
print(type(var))
print("type of variable: " + str(type(var))) # python v. 3 cast type to string
Javascript typeof()[4]
# define the variable
var a = 3.14159;
# print type of the variable
typeof a;
console.log("type of variable:: " + typeof a);
R: typeof()
references
Troubleshooting of ...
- PHP, cUrl, Python, selenium, HTTP status code errors
- Database: SQL syntax debug, MySQL errors, MySQLTuner errors or PostgreSQL errors
- HTML/Javascript: Troubleshooting of javascript, XPath
- Software: Mediawiki, Docker, FTP problems, online conference software
- Test connectivity for the web service, Web Ping, Network problem, Web user behavior, Web scrape troubleshooting
Template