首页 > Web开发 > 详细

php数据类型

时间:2017-06-24 09:13:45      阅读:271      评论:0      收藏:0      [点我收藏+]

一般PHP的数据类型不是由程序员定义 PHP会根据它的值自动匹配类型

四种标量类型:

两种复合类型:

最后是两种特殊类型:

var_dump(): 查看某个表达式的值和类型 

 gettype()   如果只是想得到一个易读懂的类型的表达方式用于调试,用

is_type() 判断类型

<?php 
$a_bool = TRUE; // a boolean 
$a_str = "foo"; // a string 
$a_str2 = ‘foo‘; // a string 
$an_int = 12; // an integer 

echo gettype($a_bool); // prints out: boolean 
echo gettype($a_str); // prints out: string 

// If this is an integer, increment it by four 
if (is_int($an_int)) { 
$an_int += 4; 
} 

// If $bool is a string, print it out 
// (does not print out anything) 
if (is_string($a_bool)) { 
echo "String: $a_bool"; 
} 
?> 

 

 查看某个类型

php数据类型

原文:http://www.cnblogs.com/YangJM/p/7072386.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!