w3resource

php.js : is_scalar() function

is_scalar() function

The is_scalar() function is used to check whether a variable is a scalar or set or not. The function returns true if the value is a scalar otherwise false.

Version:

1103.1210

Syntax:

is_scalar(variable_name)

Parameters:

Name Description Required /
Optional
Type
variable_name The variable being checked Required Mixed*

*Mixed : Mixed indicates that a parameter may accept multiple (but not necessarily all) types.

Example of php.js is_scalar() function

In the following web document is_scalar() function test whether a value is scalar or not.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>php.js : is_scalar() function example</title>
<script type="text/javascript" src="../../phpjs/variable/variable.min.js"> </script>
</head>
<body>
<h1 style="color: green">php.js : is_scalar() function example</h1>
<h3>Function returns true if value is a scalar...</h3>
<hr />
<script type="text/javascript">
//This is done to make the following JavaScript code compatible to XHTML. <![CDATA[
var_name='A';
if (is_scalar(var_name))
document.write('The value is a scaler...'+'<br />');
else
document.write('The value is not scaler...'+'<br />');
var_name=2658.56
if (is_scalar(var_name))
document.write('The value is a scaler...');
else
document.write('The value is not scaler...');
//]]>
</script>
</body>
</html>

View example of php.js is_scalar() function in browser

Download phpjs.zip

Previous: php.js : is_resource() function
Next: php.js : is_string() function



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://www.w3resource.com/phpjs/variable/is_scalar.php