数据类型bollean interger float string array object resource NULL callback/callable

输出 echo print print_r  var_dump

echo输出*arr不输出object语法错误

print同echo

print_r同print不过array输出键和值object不报错

var_dump同print_r不过还有输出数据类型常为开发用

<?php
class objecttt{
    function foo(){
        echo "this a object";
    }
}
$booleann=true;
$intt=123;
$floatt=12.3;
$stringg="sstrr";
$arrayy=array("first","two","secend");
$objectt=new objecttt;
$objectt->foo();
echo $booleann."boolean&nbsp";
echo $intt."int&nbsp";
echo $floatt."float&nbsp";
echo $stringg."string&nbsp";
echo $arrayy."array&nbsp<br>";
//echo $objectt."object&nbsp<br>";
print $booleann."boolean&nbsp";
print $intt."int&nbsp";
print $floatt."float&nbsp";
print $stringg."string&nbsp";
print $arrayy."array&nbsp<br>";
//print $objectt."object&nbsp<br>";
//print_r $booleann."boolean&nbsp";
//print_r $intt."int&nbsp";
print_r($floatt);
print_r($stringg);
print_r($arrayy);
print_r($objectt);
echo "<br>";
var_dump($floatt);
var_dump($stringg);
var_dump($arrayy);
var_dump($objectt);
echo "<br>"
?>

 php值类型不需要定义为自动转换

https://www.php.net/manual/zh/language.types.type-juggling.php

php类型比较

== 松散比较只比较值不比较类型

===严格比较比较值也比较类型要全一样

参考https://www.runoob.com/php/php-types-comparisons.html

posted on 2020-07-28 21:18  浩空之梦  阅读(352)  评论(5编辑  收藏  举报