简体   繁体   English

php数组 - 大写或小写

[英]php array - upper case or lower case

Does it matter whether an uppercase or lower case a is used for php arrays? 是否将大写或小写a用于php数组?

For example: array() vs. Array() 例如: array()Array()

I believe the OP is referring to this: 我相信OP指的是:

<?php
$arr = array("foo" => "bar", 12 => true);
var_dump($arr);
// returns array(2) { ["foo"]=>  string(3) "bar" [12]=>  bool(true) }

$arr = Array("foo" => "bar", 12 => true);
var_dump($arr);
// also returns array(2) { ["foo"]=>  string(3) "bar" [12]=>  bool(true) }
?>

So the answer is no, there is no difference 所以答案是否定的,没有区别

If you mean: 如果你的意思是:

$array = Array(1,2,3);

vs VS

$array = array(1,2,3);

vs VS

$array = aRRaY(1,2,3);

there is no functional difference. 没有功能差异。 It is only a question of style. 这只是一种风格问题。 Like PHP functions, the array language construct is case-insensitive. 与PHP函数一样, 数组语言构造不区分大小写。

If you mean array names/variables, then yes it does, PHP variables are case-sensitive . 如果你的意思是数组名称/变量,那么是的,PHP变量是区分大小写的 If however, you are asking about standards, have a look at: 但是,如果您要询问标准,请查看:

PHP Coding Standard about Naming Conventions 关于命名约定的PHP编码标准

David - yes it does. 大卫 - 是的。 they are treated as different variables $varPerson and $varperson. 它们被视为不同的变量$ varPerson和$ varperson。

However, the main thing really is more that you should be following some kind of coding guideline doc that mandates case and scope of all variables. 但是,最重要的是你应该遵循某种编码指南doc,它要求所有变量的大小写和范围。 this is probably a much more important driver of variable naming/case than the simple question implies. 这可能是变量命名/案例的一个更重要的驱动因素,而不是简单的问题所暗示的。

jim 吉姆

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM