H I O X INDIA
FREE PHP Topics
 HOME  ||  Scripts  ||  Purchase  ||  Tutorials  ||  Images  ||  Tools  ||  Directories 
  :-)  Send Page   :-)   Feedback   :-)   Register   :-)   Links   :-)   Support   :-)   Bookmarks :-)  
 Forums   Hosting   Internet Stats   Easy Calculation   FUN Games 

PHP Topics
Introduction
Common Header
Random Number
Type
Form Variables
Date and Time
File Handling
Error Handling
DB Size
PHP Mail
String Tokens
Running PHP from JS
Array To JS
Array to PHP
Encryption
Ask Your Doubts
Feedback





Boolean data type in PHP


Topic

How to define a boolean variable and assign value?



Explanation

A boolean type is typically denoted by "bool" or "boolean".It can hold values either "true" (1) or "false" (0). Any non zero values and non empty string are also considered as TRUE.

When you want to declaring boolean variable, you can declare as given below

boolean $variable;

where boolean denotes the type of the variable.

You can also declare variable without datatype, in such case PHP will try to determine type of variable based on the value hold by that variable. For example if you assign a string value to variable, this variable becomes a string variable. Below I have declared a variable without its type.

$variable= true;

Here $variable is a variable of type boolean.

If you want to get a type of a variable, you can use gettype() function.
Example:

$variable=true;
print gettype($variable);


Above code will print type as boolean.




others


privacypolicy     licence     sitemap
(c) copyright, 2004 hioxindia.com