Home  >  Article  >  Backend Development  >  Do all values ​​in php arrays have double quotes?

Do all values ​​in php arrays have double quotes?

青灯夜游
青灯夜游Original
2022-06-02 16:07:582321browse

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.

Do all values ​​in php arrays have double quotes?

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",&#39;true&#39;,true,3.24);
var_dump($arr);
?>

Do all values ​​in php arrays have double quotes?

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(&#39;content-type:text/html;charset=utf-8&#39;);   
//双引号方式声明字符串
$str1 = "PHP中文网";  
//单引号方式声明字符串
$str2 = &#39;PHP 教程&#39;;      
//Heredoc 方式声明字符串
$str3 = <<<EOF
    url:
    //m.sbmmt.com/
EOF;
echo $str1."<br>".$str2."<br>".$str3;
?>

Do all values ​​in php arrays have double quotes?

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!

Statement:
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