Print variable types

From LemonWiki共筆
Revision as of 16:34, 8 April 2018 by Planetoid (talk | contribs)
Jump to navigation Jump to search

Print the type of the variable or just print the variable

Print the 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()


Print the variable

PHP

# define the variable
$var = 3.14159;

echo print_r($var, true) . PHP_EOL;
var_dump($var);

Python

# define the variable
var = 3.14159

print(var)) # python v. 3

References

Related articles


Troubleshooting of ...

Template