PHP data types and judgment variable types

巴扎黑
Release: 2023-03-03 11:36:01
Original
1385 people have browsed it

PHP data types include: string, integer, floating point number, Boolean, array, object, NULL.

How to determine the variable type, use the var_dump function.
The var_dump function is to determine the type and length of a variable and output the value of the variable. If the variable has a value, it will lose the value of the variable and return the data type.

<meta charset="UTF-8">
<?php
$val1 = 1;
$val2 = 3.14;
$val3 = &#39;阅谁问君诵,水落清香浮。&#39;;
$val4 = array(&#39;aaa&#39;,&#39;bbb&#39;);
$val5 = true;
$val6 = function(){};
$val7 = null;
var_dump($val1);//整数
echo &#39;<br>&#39;;
var_dump($val2);//浮点数
echo &#39;<br>&#39;;
var_dump($val3);//字符串
echo &#39;<br>&#39;;
var_dump($val4);//数组
echo &#39;<br>&#39;;
var_dump($val5);//布尔
echo &#39;<br>&#39;;
var_dump($val6);//对象
echo &#39;<br>&#39;;
var_dump($val7);//NULL
?>
Copy after login

Rendering:

PHP data types and judgment variable types

PS: Since the encoding used is UTF-8, each Chinese character occupies 3 bytes, while each English character occupies 1 byte.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template