Home > php教程 > php手册 > body text

php中{}大括号是什么意思

WBOY
Release: 2016-06-13 10:18:15
Original
1133 people have browsed it

1、 {} 表示程序块的开始和结束

例如

复制代码 代码如下:


if ($x==$y)
{
 do_nothing();
}


2、 {}用来表示字符串下标

例如
(引用longnetpro兄弟的话)
$s{1}表示字符串$s的第2个字节(不是第一个),基本等同于$s[1],只不过后者是老的写法,PHP手册推荐第一种写法 www.444p.com版权所有

3、分离变量

例如

复制代码 代码如下:


$s = "Di, ";
echo ("${s}omething");
//Output: Di, omething


而如果用echo ("$something");
那么就会输出 $something 这个变量。
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template