Home  >  Q&A  >  body text

给数组赋值要用双引号还是不用加双引号?

比如:

var arr=new Array();

arr[0]=这里加不加双引号呀

你的名字你的名字2863 days ago3754

reply all(4)I'll reply

  • 钟毅

    钟毅2017-10-04 14:32:58

    arr[0]=The following mainly depends on what type of data content you want to put. For numeric types, no explicit annotation is required. Characters and symbols must be enclosed in double quotes. Of course, if your subscript is a character, you need to add double quotes. This requires special attention. The variable must specify the type of storage. PHP is automatically transformed.

    reply
    0
  • 数据分析师

    数据分析师2017-09-30 22:44:51

    Should we use double quotes or not when assigning values ​​to an array? - PHP Chinese website Q&A - Should we use double quotes or not when assigning values ​​to an array? - PHP Chinese website Q&A

    Take a look around and learn.

    reply
    0
  • 蝎子

    蝎子2017-07-24 10:59:13

    The key name in the array is a variable, and the key value is equivalent to the value of the variable. If there is no variable in a string, it is best to add single quotes. Double quotes will parse the variable, which can be slower according to logic

    reply
    0
  • 阿神

    阿神2016-12-17 13:21:04

    如果是给数组添加数字型 则可以不加双引号 arr[0] =99;

    要是字符串的话就得加上双引号或单引号 : arr[1] = ‘张三’;

    reply
    0
  • Cancelreply