Home > Backend Development > PHP Tutorial > php自动类型转换,要遵循什么规则?

php自动类型转换,要遵循什么规则?

WBOY
Release: 2016-06-23 14:18:22
Original
988 people have browsed it

本帖最后由 u011523116 于 2013-08-05 11:49:57 编辑

有这方面的官方文档(中文翻译)么?

回复讨论(解决方案)

基本原则:
对于数学运算,字符串转换为数值
对于字符串运算,数值转换为字符串

基本原则:
对于数学运算,字符串转换为数值
对于字符串运算,数值转换为字符串

给个实例!

echo 1 + "2a";//3
echo 1 . "2a";//12a

echo 1 + "2a";//3
echo 1 . "2a";//12a

点号 . 有什么作用?

字符串连接
似乎你的学习方法有问题

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