PHP中不使用';没有道理
我正在试验PHP的弱/动态类型属性,为测试做准备,但这个字符串连接的输出完全让我困惑。有人能解释一下这是怎么可能的吗PHP中不使用';没有道理,php,dynamic-typing,weak-typing,Php,Dynamic Typing,Weak Typing,我正在试验PHP的弱/动态类型属性,为测试做准备,但这个字符串连接的输出完全让我困惑。有人能解释一下这是怎么可能的吗 <?php echo 1 . "/n" . '1' + 1 ?><br /> 输出: 二, 分析: echo 1 . "/n" . '1' + 1; 相当于 //joined first 3 items as string echo "1/n1"+1; 相当于 //php faces '+' operator, it parses '1/n1
<?php echo 1 . "/n" . '1' + 1 ?><br />
输出:
二,
分析:
echo 1 . "/n" . '1' + 1;
相当于
//joined first 3 items as string
echo "1/n1"+1;
相当于
//php faces '+' operator, it parses '1/n1' as number
//it stops parsing at '/n' because a number doesn't
//contain this character
echo "1"+1;
echo 1+1;
相当于
//php faces '+' operator, it parses '1/n1' as number
//it stops parsing at '/n' because a number doesn't
//contain this character
echo "1"+1;
echo 1+1;
查看在您
echo intval(“1/n1”)之后它是否更有意义代码>看一下哈哈,我不认为这会更有意义,但它会显示解决方案。另外,@skj3gg我也在想同样的事情-至少这些废话被记录下来了。这是预期的输出