Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/268.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP中不使用';没有道理_Php_Dynamic Typing_Weak Typing - Fatal编程技术网

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的弱/动态类型属性,为测试做准备,但这个字符串连接的输出完全让我困惑。有人能解释一下这是怎么可能的吗

<?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我也在想同样的事情-至少这些废话被记录下来了。这是预期的输出