Home > Article > Backend Development > What does string mean in PHP?
In PHP, string means "string" or "character variable", and string means a string of characters, including Chinese, English, special symbols, and a mixture of numbers are called strings .
The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer
What does string mean in PHP?
string is a "string" or a "character variable"
usually appears in PHP manuals, for example:
string $k
String variable $k, this variable is required to be a string
The simple meaning of string is: "A string of characters, including a mixture of Chinese, English, special symbols, and numbers They are all called strings"
For example:
$a='aaa11145ggg'; $b='我也是字符串啊'; $c='2008-8-23';//虽然我是日期,但是我在php里被划到了字符串里去了;但是我的兄弟时间戳是整型
These are all strings
------------------ --------
If you see int $k
, it means: integer $k, which must be a number without a decimal point (it can only be a number, but no matter Is it positive or negative)
For example:
$a=100; $b=-100;
These are integers
--------------------- ------
Since there are integers, there must be numbers with small dots. In programming languages (including PHP), it is called "floating point" floor
floor $k;
Requirement$ k is a floating point type
These are all floating point types:
$a=0.5; $b=10.5; $c=-0.5;
------------------------ -------------
Array variable: array $k;
The requirement is an array, and the array can be automatically generated by a function. We define it ourselves.
How to customize functions: array(), you can check it in the manual
I won’t go into too much detail here, you can read the manual, array has two concepts:
Key name (equivalent to the serial number in the array, can be a number or a string)
Value (equivalent to the specific data corresponding to the variable, can be any data or array, we call such an array It's a two-dimensional array. Haha, I'm far away. You can read the manual. If you need to ask, I can explain it in more detail. Of course, you can choose to contact me.)
------ --------------------------------------------------
BooleanBoolean
For programming languages, if they need to make judgments, they only know true (true) and false (false), 1 and 0, that is, the sum A simple judgment that does not hold true.
There are only two Boolean: true and false
For example, if I say 1 is greater than 5, the computer will calculate it by itself. If it is not greater, it will return false, otherwise it will return true. We use this returned true or false to proceed with the next step.
----------------------------------------
The difference between NULL and '' "" (empty string)
Many people think that these two are the same, but they are actually different.
In the database, it is obvious that empty means it does not exist; and the empty string just means that we think there is nothing in it, but in fact the computer thinks it exists.
For example: For example, two people (J and K) applied for a company together. The company hired K and signed a contract; at the same time, they told J that they were sorry that they don’t have a position for you, and that they will be available next time. inform you.
The K who signed the contract has not yet received the money, you can treat k as an empty string.
And J is just a verbal promise from the company. If there is no contract, you can understand it as empty (NULL)
In PHP, the following data will be considered as Boolean false:
1, false, including string
2, 0, empty (NULL, case-insensitive), empty array (there is an array but no elements, as if a shell company has no employees), floating point type "0.0"
-------------
That's probably it~
Recommended learning: "PHP Video Tutorial》
The above is the detailed content of What does string mean in PHP?. For more information, please follow other related articles on the PHP Chinese website!