Home > Backend Development > PHP Tutorial > PHP self-study no00011 data type conversion

PHP self-study no00011 data type conversion

WBOY
Release: 2016-07-29 08:51:01
Original
1066 people have browsed it

<!--(boolean)转成布尔型-->
<!--(string)转成字符串型-->
<!--(integer)转成整型-->
<!--(float)转成浮点型-->
<!--(array)转成数组-->
<!--(object)转成对象-->
<!--settype(变量,&#39;类型&#39;)   转后原变量改变-->
<?php $num = &#39;3.141592653r*r&#39;;
	echo &#39;使用(integer)转成整型:&#39;;
	echo (integer)$num;
	echo &#39;<p>';
	echo '不转换输出原来的变量';
	echo $num;
	echo '<p>';
	echo '使用函数settype()转换变量类型';
	settype($num,'integer');			//这里integer要单引号不然报错
	echo $num;
	echo '</p><p>';
	echo '输出函数转换后的变量';
	echo $num
    /*
	注意用函数settype()后变量本身已转换,而(float)等变量本身没变只输出变了
	*/
?></p>
Copy after login

PHP self-study no00011 data type conversion

The above introduces the PHP self-study no00011 data type conversion, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template