我正在浏览我的 GitHub 项目,
期间我发现 hp 确实支持变量名称中的连字符/破折号 (-)。
$var-a=2;
Run Code Online (Sandbox Code Playgroud)
谁能告诉我为什么?
这是因为它是算术运算符吗?php 是否不支持它们的任何其他符号?
这是因为连字符与减号相同。
我们来看一个场景:
<?php
define('name', 2);
$var = 5;
# Now when you write those combined.
$var-name; # This is actually $var minus name which is a constant.
# Same format as $var1-$var2. Except for this case there is a constant in place of $var2.
?>
Run Code Online (Sandbox Code Playgroud)
这是变量中没有连字符的主要原因。
| 归档时间: |
|
| 查看次数: |
4626 次 |
| 最近记录: |