w3resource logo


php.js - empty function - php.js Tutorial

php.js : empty() function

Secondary Nav

Description

The empty() function checks whether a variable is empty or not and returns true or false.

Version

1103.1210

Syntax

empty(var_name)

Parameters

Name Description Required /
Optional
Type
var_name The variable to be checked. Required Mixed*

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

Example of php.js empty() function

In the following web document empty() function checks whether a value is empty 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 : empty() function example</title>
<script type="text/javascript" src="../../phpjs/variable/variable.min.js"> </script>
</head>
<body>
<h1 style="color: green">php.js : empty() function example</h1>
<h3>Test whether a value is empty or not.</h3>
<hr />
<script type="text/javascript">
//This is done to make the following JavaScript code compatible to XHTML. <![CDATA[
document.write("empty('')"+'<br />');
document.write(empty('')+'<br />');
document.write("empty(null)"+'<br />');
document.write(empty(null)+'<br />');
//]]>
</script>
</body>
</html>

Output of the function

empty('')
true
empty(null)
true

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

Download phpjs.zip



Join our Question Answer community to learn and share your programming knowledge.

Help the community:

Python: Fizzbuzz

C++: Decimal to binary conversion

JavaScript: Need Help in JavaScript

Python: Help me with this program