Home  >  Article  >  php教程  >  php 数字型转换成字符型方法

php 数字型转换成字符型方法

WBOY
WBOYOriginal
2016-05-25 16:42:451613browse

方法很简单PHP字符串int是很容易,只要在变量前面加个(int)就成了,转换成字符也一样的,代码如下:

$str = "10";    
$num = (int)$str; 
//
$str = "10"; 
$num = (int)$str; 
if ($str === 10) echo "string";
if ($num === 10) echo "integer"; 
/* 
结果为 
integer 
*/ 
echo gettype($str); //string 
echo gettype($num); //integer


本文地址:

转载随意,但请附上文章地址:-)

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn