PHP’s data types include the following,
Integer (integer type)
String(String)
Float(Float type),
Boolean(Boolean type)
Array(array)
Object(object)
NULL(null value)
View data type
1. gettype (pass in a variable) can get the type of the variable
2. var_dump (pass in a variable) output variable type and value (most commonly used)
var_dump() is a function. Insert variables between brackets (). This function will print out the data type and also display the length and value of the variable accordingly.
##Integer type (int)
The integer type is divided into :
1. 10-base system 2.8-base system ( Understand, basically don’t use it)
3.16 base (Understand, basically don’t use it)
Octal system declaration: starts with 0, followed by an integer from 0 to 7 (Understand knowledge points) Hexadecimal declaration: Starting with 0x, followed by 0-f, the abcdef of 0x is not case-sensitive. (Understand knowledge points)Integer rules:
· An integer must have at least one digit (0-9) · The integer cannot contain commas or spaces· The integer cannot have a decimal point· The integer can be positive or negative· The integer can be specified in three formats: decimal, hexadecimal System (prefix is ??0x) or octal (prefix is ??0)#Example
In the following example we will test different numbers.
<?php $x = 5985; //十进制 var_dump($x); echo "<br>"; $x = -345; // 负数 var_dump($x); echo "<br>"; $x = 0x8C; // 十六进制数 var_dump($x); echo "<br>"; $x = 047; // 八进制数 var_dump($x); ?>
Strings are all our visible and invisible characters. They are what we say in daily life. What I want to say is: "Li Wenkai is so handsome." ” or “Sister Feng, I love you!” Strings are all the characters that people can see that I want to express.
For example, you can see the characters: I would like to become you, the prince you love, a house, a car and money, in a fairy tale. <html><title></title></html> ^@@@#@ my name is xiaoshenyang and above text, HTML tags, special characters and English, etc., we all Think it is a stringThere are three ways to declare a string in PHP language:
1. Use single quotes to declare
2. Use double quotes to declare
3. Use character delimiters Statement (used when a very large string needs to be entered)
1.Single quote statement Use English half-foot single quotes to wrap the string, as follows:
$zifuchuan= 'I am a single quote';
1. Double quote statement Add double quotes on both sides of the string, as follows:
$zifuchuan= "I am double quotes";
3. Character declaration
1). Write three less than signs (<<<) after the equal sign after the variable.
2). Then write characters after <<< (English uppercase characters are recommended). As in the following example: ABC
3). Then change the line and write any characters you want
4). After writing, go to the top line. At the beginning of the line, write the characters following <<< and a semicolon. As in the following example: ABC;
<?php
$dingjie = <<<ABC
If
It must be here Roll the calf
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Far, get as far away from me</h1>
ABC;
?>
##Example
In the following example, we will output a string. <?php
$x = "Hello world!";
echo $x;
echo "<br>";
$x = 'Hello world!';
var_dump($x) ;
?>
##Float
The so-called floating point type can be understood as: the decimal in our mathematics.
Example
We use echo and Print to output floating point types respectively <?php
//声明变量fudian的值为12121.3132
$fudian = 12121.3132;
echo $fudian;
echo "<br>";
//声明变量$fl 的值为0.8873
$fl = 0.8873;
var_dump($fl);
?>
echo directly outputs 12121.3132, and var_dump The output is 0.8873, and it also shows that the type of variable $fl is float.
##Boolean type(bool)
The Boolean type is: true and false. The translation of true and false in English is: · true (true)
· false (false)
Therefore, we can do this in the PHP code statement.
<?php
//Declare a variable (Pinyin) as Boolean
$buer = true;
//State a variable (English)
$bool = false;
?>
Note: Do not add quotation marks around for true and false.
#Array
<?php $cars=array("Volvo","BMW","SAAB"); var_dump($cars); ?>You will learn more about arrays later in this tutorial.
Object (Object)
#NULL (null value)<?php class Car
{
var $color;
function Car($color="green") {
$this->color = $color;
}
function what_color() {
??????????? return $this->color;
??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????Knowledge about objects, just know it now
There are three main situations that will produce a null type: 1. The value of a variable explicitly specified as NULL through variable assignment
2. A variable has no Give any value
3. Use the function unset() to destroy the variable
Let’s demonstrate it with code
<?php //声明变量为null $n = null; var_dump($n); //var_dump显示输出变量$meiyou,看看结果是什么? var_dump($meiyou); //声明一个变量$iphone的值为字符串的手机 $iphone = '手机'; //unset销毁掉一个变量 unset($iphone); var_dump($iphone); ?>
Next we will explain two things related to null Functions, these two functions are very commonly used.
empty()
You can pass a variable into the middle of the brackets. If the value of this variable is false or null, it returns true.
Example<?php
header("Content-type:text/html;charset=utf-8"); //设置utf-8编码
$apple = null;
if(empty($apple)){
echo '执行了真区间';
}else{
echo '行了假区间';
}
?>
##The above experiment proves that $apple is null. Place the apple in the middle of empty. The result is a true interval.
isset()You can pass one or more variables into the middle of the brackets, and separate variables with commas. As long as there is a variable that is null, it returns false. Otherwise, returns true.
Example
<?php $one = 10; $two = false; $three = 0; $four = null; $result = isset($one , $two , $three , $four); //执行看看结果,是不是 var_dump($result); ?>
##unset()The function of this function is to destroy variables. Insert the variable name you want to destroy between the unset (variable) brackets, and the variable will be destroyed.
什么是间质性肺炎 | 股票洗盘是什么意思 | 什么是崩漏 | 什么颜色对眼睛有好处 | 夏季风寒感冒吃什么药 |
碧螺春是什么茶 | 蒲公英泡水喝有什么功效 | ads是什么 | 病毒五项检查的是什么 | 出征是什么意思 |
生命的本质是什么 | 心肌酶高是什么意思 | 小孩尿酸高是什么原因 | no.是什么意思 | 1109是什么星座 |
80岁称什么之年 | 耵聍栓塞是什么意思 | 耳机戴久了有什么危害 | 豌豆荚是什么 | 就义是什么意思 |
什么耳什么腮hcv9jop3ns4r.cn | 话糙理不糙是什么意思hcv9jop4ns1r.cn | 海马用什么呼吸hcv8jop8ns7r.cn | 贫血喝什么口服液hcv8jop1ns3r.cn | 嗳腐吞酸是什么意思hcv7jop7ns0r.cn |
二月春风似剪刀的上一句是什么beikeqingting.com | 农历七月初七是什么节日hcv9jop3ns7r.cn | 脸上发红是什么原因hcv9jop3ns7r.cn | 无济于事的济是什么意思hcv8jop7ns4r.cn | 夜游神是什么意思hcv8jop4ns0r.cn |
为什么一直睡不着hcv8jop0ns8r.cn | hdl是什么意思hcv9jop5ns4r.cn | 水漂是什么意思hcv8jop6ns3r.cn | 且行且珍惜什么意思hcv9jop0ns2r.cn | 传字五行属什么hcv9jop5ns4r.cn |
左侧卵巢内囊性回声是什么意思hcv9jop4ns5r.cn | mds是什么病的简称luyiluode.com | 鼻窦炎是什么原因引起的呢hcv9jop4ns6r.cn | 10月24号是什么星座hcv8jop7ns7r.cn | 丘比特是什么意思hcv7jop6ns3r.cn |