Home > Backend Development > PHP Tutorial > PHP中如下代码

PHP中如下代码

WBOY
Release: 2016-06-06 20:15:23
Original
913 people have browsed it

代码foreach((array)$a as $b=>$c){}中
(array)什么意思,解释性语言吗?

回复内容:

代码foreach((array)$a as $b=>$c){}中
(array)什么意思,解释性语言吗?

这个叫强制类型转换,表示如果变量$a不为array数组类型,则强制将其转换为array类型。

对于强制转换的规则,参阅下面的PHP文档
http://php.net/manual/zh/language.types.array.php#language.types.array.casting

强制类型转换,强制转化为数组

强制类型转换
类似的还有
$val = 123.456;
(int)$val
(string)$val
等等

Related labels:
php
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