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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-25 16:42:45
Original
1734 people have browsed it

方法很简单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
Copy after login


本文地址:

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

Related labels:
php
Statement of this Website
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
Latest Issues
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template