<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Erick &#187; 大括号</title>
	<atom:link href="http://blog.xiongchuan.org/tag/braces/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.xiongchuan.org</link>
	<description>Even a great life is only a life until you make it.</description>
	<lastBuildDate>Thu, 10 Mar 2011 14:44:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1</generator>
	
<!-- Start Of Script Generated By WP-PostViews Plus -->
<script type='text/javascript' src='http://blog.xiongchuan.org/wp-includes/js/jquery/jquery.js?ver=1.4.4'></script>
<script type="text/javascript">
/* <![CDATA[ */
/* ]]> */
</script>
<!-- End Of Script Generated By WP-PostViews Plus -->
	<item>
		<title>PHP的大括号，详解</title>
		<link>http://blog.xiongchuan.org/php-braces-description.html</link>
		<comments>http://blog.xiongchuan.org/php-braces-description.html#comments</comments>
		<pubDate>Mon, 15 Jun 2009 08:28:46 +0000</pubDate>
		<dc:creator>Erick</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[大括号]]></category>

		<guid isPermaLink="false">http://www.wp.com/wordpress/?p=76</guid>
		<description><![CDATA[本文原创，转载请注明出处，谢谢合作！ 今天更新了日志，点Tag：面试，结果出来了一些不相关的东西，感觉很奇怪，把SQL导出，我在本地调了下，发现原来是 SQL语句里的问题。 代码如下 select * from blog_blogs where blog_tags like &#8216;%{$k}%&#8217; order by blog_id 因为Tags的ID是用大括号分开的，就是{1}{2}这样形式，但是用以上语句查询得不出正确结果，原因就是这个语句最终变成了 代码如下 select * from blog_blogs where blog_tags like &#8216;%$k%&#8217; order by blog_id 这样的形式，哎 ！现在就来说说PHP里大括号的作用吧。 一、不管什么程序，function name(){},  for(){}, &#8230;.这太多了，不说也知道什么用了。 二、$str{4}在字符串的变量的后面跟上{}刚大括号和中括号一样都是把某个字符串变量当成数组处理 三、{$val}这种情况就是我遇到的问题，这时候大括号起的作用就是，告诉PHP，括起来的要当成变量处理。看下一个简单的代码 代码如下 &#60;?php Header(&#8216;content-type:text/html;charset=utf-8&#8242;); $array=array( 0=&#62;123, 1=&#62;234, &#8216;pig&#8217;=&#62;&#8216;www.pigblog.net&#8217;, &#8216;name&#8217;=&#62;&#8216;小猪&#8217;, ); foreach($array as $k=&#62;$v){ echo &#8220;select * from blog_blogs where blog_tags like [...]]]></description>
			<content:encoded><![CDATA[<p>本文原创，转载请注明出处，谢谢合作！</p>
<p>今天更新了日志，点Tag：面试，结果出来了一些不相关的东西，感觉很奇怪，把SQL导出，我在本地调了下，发现原来是<br />
SQL语句里的问题。</p>
<div style="border: 1px dashed #cccccc;">
<div style="border-bottom: 1px dashed #cccccc; padding: 5px 10px; height: 20px; line-height: 20px; font-weight: bold;">代码如下</div>
<ol>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;">select <span style="color: #339933;">*</span> from <span style="color: #666666; font-style: italic;">blog_blogs where blog_tags like &#8216;%{$k}%&#8217; order by blog_id</span></div>
</li>
</ol>
</div>
<p>因为Tags的ID是用大括号分开的，就是{1}{2}这样形式，但是用以上语句查询得不出正确结果，原因就是这个语句最终变成了</p>
<div style="border: 1px dashed #cccccc;">
<div style="border-bottom: 1px dashed #cccccc; padding: 5px 10px; height: 20px; line-height: 20px; font-weight: bold;">代码如下</div>
<ol>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;">select <span style="color: #339933;">*</span> from <span style="color: #666666; font-style: italic;">blog_blogs where blog_tags like &#8216;%$k%&#8217; order by blog_id</span></div>
</li>
</ol>
</div>
<p>这样的形式，哎 ！现在就来说说PHP里大括号的作用吧。<br />
一、不管什么程序，function name(){},  for(){}, &#8230;.这太多了，不说也知道什么用了。<br />
二、$str{4}在字符串的变量的后面跟上{}刚大括号和中括号一样都是把某个字符串变量当成数组处理<br />
三、{$val}这种情况就是我遇到的问题，这时候大括号起的作用就是，告诉PHP，括起来的要当成变量处理。看下一个简单的代码<br />
<span id="more-76"></span></p>
<div style="border: 1px dashed #cccccc;">
<div style="border-bottom: 1px dashed #cccccc; padding: 5px 10px; height: 20px; line-height: 20px; font-weight: bold;">代码如下</div>
<ol>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #000000; font-weight: bold;">&lt;?php</span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #990000;">Header</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&#8216;content-type:text/html;charset=utf-8&#8242;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #000088;">$array</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span><span style="color: #009900;">(</span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #cc66cc;">0</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">123</span><span style="color: #339933;">,</span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #cc66cc;">1</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">234</span><span style="color: #339933;">,</span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #0000ff;">&#8216;pig&#8217;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&#8216;www.pigblog.net&#8217;</span><span style="color: #339933;">,</span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #0000ff;">&#8216;name&#8217;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&#8216;小猪&#8217;</span><span style="color: #339933;">,</span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #009900;">)</span><span style="color: #339933;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="background-color: #cccccc;"><span style="color: #b1b100;">foreach</span><span style="color: #009900;">(</span><span style="color: #000088;">$array</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$k</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$v</span><span style="color: #009900;">){</span></span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="background-color: #cccccc;"> <span style="color: #990000;">echo</span> <span style="color: #0000ff;">&#8220;select * from blog_blogs where blog_tags like <span style="text-decoration: underline;">&#8216;%{<span style="color: #006699; font-weight: bold;">$array</span>[<span style="color: #006699; font-weight: bold;">$k</span>]}<span style="color: #009933; font-weight: bold;">%&#8217;</span></span><span style="color: #009933; font-weight: bold;"> o</span>rder by blog_id&#8221;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&#8216;&lt;br&gt;&#8217;</span><span style="color: #339933;">;</span></span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="background-color: #cccccc;"><span style="color: #009900;">}</span></span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #000000; font-weight: bold;">?&gt;<br />
输出为：<br />
select * from blog_blogs where blog_tags like &#8216;%123%&#8217; order by blog_id<br />
select  * from blog_blogs where blog_tags like &#8216;%234%&#8217; order by blog_id<br />
select * from  blog_blogs where blog_tags like &#8216;%www.pigblog.net%&#8217; order by blog_id<br />
select *  from blog_blogs where blog_tags like &#8216;%小猪%&#8217; order by blog_id<br />
</span></div>
</li>
</ol>
</div>
<p>从上面就可以看出我的代码出错的原因了。<br />
把上面灰色的换成如下</p>
<div style="border: 1px dashed #cccccc;">
<div style="border-bottom: 1px dashed #cccccc; padding: 5px 10px; height: 20px; line-height: 20px; font-weight: bold;">代码如下</div>
<ol>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #b1b100;">foreach</span><span style="color: #009900;">(</span><span style="color: #000088;">$array</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$k</span><span style="color: #339933;">=&gt;</span><span style="color: #000088;">$v</span><span style="color: #009900;">)</span><span style="color: #009900;">{</span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #990000;">echo</span> <span style="color: #0000ff;">&#8220;select * from blog_blogs where blog_tags like <span style="text-decoration: underline;">&#8216;%{{<span style="color: #006699; font-weight: bold;">$array</span>[<span style="color: #006699; font-weight: bold;">$k</span>]}}<span style="color: #009933; font-weight: bold;">%&#8217;</span></span><span style="color: #009933; font-weight: bold;"> o</span>rder by blog_id&#8221;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&#8216;&lt;br&gt;&#8217;</span><span style="color: #339933;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #009900;">}<br />
输出为：<br />
select * from blog_blogs where blog_tags like &#8216;%{123}%&#8217; order by  blog_id<br />
select * from blog_blogs where blog_tags like &#8216;%{234}%&#8217; order by  blog_id<br />
select * from blog_blogs where blog_tags like &#8216;%{www.pigblog.net}%&#8217;  order by blog_id<br />
select * from blog_blogs where blog_tags like &#8216;%{小猪}%&#8217; order  by blog_id<br />
</span></div>
</li>
</ol>
</div>
<p>对比一下画线的地方，就是这里改了下，这样就正确了。</p>
<p>那现在自己想一下，本来PHP里如果用 <span style="color: #ff0000;"><span style="text-decoration: underline;">双引号</span></span> 就会自动识别变量，怎么还搞个大括号？<br />
目前我的经验是：在双引号里，如果用显示的关联数组就会报出语法错误，出错语句如下</p>
<div style="border: 1px dashed #cccccc;">
<div style="border-bottom: 1px dashed #cccccc; padding: 5px 10px; height: 20px; line-height: 20px; font-weight: bold;">代码如下</div>
<ol>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #990000;">Header</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&#8216;content-type:text/html;charset=utf-8&#8242;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #000088;">$array</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span><span style="color: #009900;">(</span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #cc66cc;">0</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">123</span><span style="color: #339933;">,</span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #cc66cc;">1</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">234</span><span style="color: #339933;">,</span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #0000ff;">&#8216;pig&#8217;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&#8216;www.pigblog.net&#8217;</span><span style="color: #339933;">,</span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #0000ff;">&#8216;name&#8217;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&#8216;小猪&#8217;</span><span style="color: #339933;">,</span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #009900;">)</span><span style="color: #339933;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #990000;">echo</span> <span style="color: #0000ff;">&#8220;<span style="color: #006699; font-weight: bold;">$array</span>['name']&#8220;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&#8216;&lt;br&gt;&#8217;</span><span style="color: #339933;">;<br />
输出为：<br />
<strong>Parse error</strong>: parse error, expecting `T_STRING&#8217; or `T_VARIABLE&#8217; or  `T_NUM_STRING&#8217; in <strong>D:\xc_blog\1.php</strong> on line <strong>9</strong><br />
</span></div>
</li>
</ol>
</div>
<p>但是如果变成这样的代码，就是在双引号里，用大括号就是正常的。</p>
<div style="border: 1px dashed #cccccc;">
<div style="border-bottom: 1px dashed #cccccc; padding: 5px 10px; height: 20px; line-height: 20px; font-weight: bold;">代码如下</div>
<ol>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #990000;">Header</span><span style="color: #009900;">(</span><span style="color: #0000ff;">&#8216;content-type:text/html;charset=utf-8&#8242;</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #000088;">$array</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span><span style="color: #009900;">(</span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #cc66cc;">0</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">123</span><span style="color: #339933;">,</span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #cc66cc;">1</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">234</span><span style="color: #339933;">,</span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #0000ff;">&#8216;pig&#8217;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&#8216;www.pigblog.net&#8217;</span><span style="color: #339933;">,</span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #0000ff;">&#8216;name&#8217;</span><span style="color: #339933;">=&gt;</span><span style="color: #0000ff;">&#8216;小猪&#8217;</span><span style="color: #339933;">,</span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #009900;">)</span><span style="color: #339933;">;</span></div>
</li>
<li style="font-weight: normal; vertical-align: top;">
<div style="margin: 0pt; padding: 0pt; background: transparent none repeat scroll 0% 0%; font-family: monospace; font-style: normal; font-variant: normal; font-weight: normal; font-size: 1em; line-height: 1.2em; font-size-adjust: none; font-stretch: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; vertical-align: top;"><span style="color: #990000;">echo</span> <span style="color: #0000ff;">&#8220;<span style="color: #006699; font-weight: bold;">{$array['name']}</span>&#8220;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&#8216;&lt;br&gt;&#8217;</span><span style="color: #339933;">;<br />
输出为：<br />
小猪<br />
</span></div>
</li>
</ol>
</div>
<p>所以说，大括号还是很有用的。当然了，你也可以把数组变量和双引号分开就不用大括号了，个人喜好吧。</p>
<p>小生也是PHP新手，如若有错还请大大们及时指正批评，在这先谢谢啦<img src="http://www.pigblog.net/include/FCKeditor/editor/images/smiley/msn/angel_smile.gif" alt="" /></p>
<h4  class="entry-title">Related Posts</h4><ul class="related_post"><li><a href="http://blog.xiongchuan.org/batch-delete-blank-lines.html" title="PHP批量删除空行|wordpress迁移的艰辛">PHP批量删除空行|wordpress迁移的艰辛</a></li><li><a href="http://blog.xiongchuan.org/centos-5-3-apache2-mysql5-php-5-3-server.html" title="CentOS 5.3搭建Apache2.2.4+Mysql5.1.4+PHP5.3服务器">CentOS 5.3搭建Apache2.2.4+Mysql5.1.4+PHP5.3服务器</a></li><li><a href="http://blog.xiongchuan.org/warning-strtotime-function-strtotime-it-is-not-safe-to-rely-on-the-system-timezone-settings-resolve.html" title="Warning: strtotime() [function.strtotime]: It is not safe to rely on the system’s timezone settings. 解决方法">Warning: strtotime() [function.strtotime]: It is not safe to rely on the system’s timezone settings. 解决方法</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.xiongchuan.org/php-braces-description.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

