Heim  >  Artikel  >  Backend-Entwicklung  >  php 运算符请问

php 运算符请问

WBOY
WBOYOriginal
2016-06-13 10:12:25801Durchsuche

php 运算符请教
$a = "24 five 6" + 6;
echo $a."
";
输出为什么是30啊?
新手多多指教

------解决方案--------------------

探讨

字符串 转为整数就是24吗?为什么呢?

------解决方案--------------------
PHP code
<?php $foo = "0";  // $foo 是字符串 (ASCII 48)$foo += 2;   // $foo 现在是一个整数 (2)$foo = $foo + 1.3;  // $foo 现在是一个浮点数 (3.3)$foo = 5 + "10 Little Piggies"; // $foo 是整数 (15)$foo = 5 + "10 Small Pigs";     // $foo 是整数 (15)?><div class="clear">
                 
              
              
        
            </div>
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn