What do you mean by "boolean" Variables in PHP?

Source: Internet
Author: User
Tags true true
Boolean-Type Boolean
For programming languages, if they need to be judged, they know only true (true) and False (false), 1 and 0, which are simple judgments that are set up and not tenable.
Boolean only two: True true, and false false

For example, I said 1 is greater than 5, the computer will calculate itself, if not greater than the return false, otherwise return true. We do the next step through the return of the true and false.

The Boolean value is typically used for conditional judgment, which is a name that actually has two true and false, both constants. Called directly.

Null (NULL) and ' "" (the difference between an empty string)
Many people think the two are the same, but they are different.
In the database it is obvious that the null representation does not exist, while the empty string is just inside we think there is nothing, but in fact the computer thinks it exists.
For example: Two people (J, and K), apply for a company together, the company to K, signed the contract, and J said, sorry, I do not have your position, the next time I will inform you.
The k that signed the contract has not got the money, you can think of K as an empty string.
And J just this company verbally agreed that without the contract you can understand as null (NULL)

In PHP, the following data is considered to be Boolean false:
1, false, including string
2, 0, empty (null, not case), empty array (with arrays but no elements, as if the shell company has no employees), float type "0.0"
In other words, except for these, the others are true~.
-------------
String is either a "literal" or a "character variable"
This is commonly seen in PHP manuals, for example:
String $k
The string variable $k, which requires that the variable be a string

The simple meaning of a string is: "A string of characters, including Chinese, English, special symbols, and numbers are all called strings"
Like what:

$a = ' aaa11145ggg '; $b = ' I am also a string '; $c = ' 2008-8-23 ';//Although I am a date, I have been drawn into the string in PHP, but my brother timestamp is the integer type

These are all strings.
--------------------------
If you see an int $k
The meaning is: the integer $k, the requirement is a number without a decimal point (only the number, but whether it is positive or negative)
For example:

$a =100; $b =-100;

These are the integral types.
---------------------------
Since there are integers, there must be numbers with dots, in programming languages (including PHP), which are called "floating-point" floor
Floor $k;
Requires $k to be floating-point
These are floating point types:

$a =0.5; $b =10.5; $c =-0.5;

--------------------------------------
Array variable: array $k;
The requirement is an array, and the array has functions that are automatically generated as well as our own definitions.
Custom Function Method: Array (), you can go to the manual to find out
Here is not much to say, you can look at the manual, the array has two concepts:
Key name (equivalent to an ordinal in an array, which can be a number or a string)
Value (equivalent to a variable corresponding to the specific data, can be any data or an array, such an array we call a two-dimensional array,

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.