Not all values in php arrays have double quotes. Any type of data can be stored in a PHP array. Only when the array element is of string type, the value will be quoted (double quotes or single quotes). Strings in PHP are continuous character sequences that can be defined through the ""String literal"" or "'String literal'" methods.
The operating environment of this tutorial: windows7 system, PHP version 8.1, DELL G3 computer
Not all values of the php array are included Double quotes.
Because PHP is a programming language with weak data types, array variables in PHP can store any number of data of any type.
Only when the array element is of type string (string), the value will be quoted (double quote or single quote), other types are not quoted.
<?php $arr=array(1,2,"1",'true',true,3.24); var_dump($arr); ?>
PHP String
The string (String) type is a period wrapped in single quotes '' or double quotes "" text, such as '123', "abc".
A string is a continuous sequence of characters. In other languages, characters and strings are two different data types, but in PHP, characters and strings are uniformly regarded as string data types.
In PHP, there are three ways to define strings, namely single quotation mark method, double quotation mark method, and Heredoc method.
<?php header('content-type:text/html;charset=utf-8'); //双引号方式声明字符串 $str1 = "PHP中文网"; //单引号方式声明字符串 $str2 = 'PHP 教程'; //Heredoc 方式声明字符串 $str3 = <<<EOF url: //m.sbmmt.com/ EOF; echo $str1."<br>".$str2."<br>".$str3; ?>
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of Do all values in php arrays have double quotes?. For more information, please follow other related articles on the PHP Chinese website!