<table cellspacing="0" cellpadding="0"><tr><td class="t_f" id="postmessage_39988"> <div class="blockcode"> <div id="code_Kd9"><ol> <li> <li><?php<li>/**<li> *php大括号例解<li> *site http://bbs.it-home.org<li>*/<li>$arr=array(0=>123, 'name'=>'小猪');</li> <li>foreach($array as $k=>$v){</li> <li> echo "select * from blog_blogs where blog_tags like '%{$arr[$k]}%' order by blog_id"; //加一个大括号只是将作为变量的标志符</li> <li>}</li> <li>echo '<br/ ><br/ ><br/ ><br/ ><br/ ><br/ ><br/ >';</li> <li>foreach($array as $k=>$v){</li> <li> echo "select * from blog_blogs where blog_tags like '%{{$arr[$k]}}%' order by blog_id"; //加两个大括号,外层的将作为普通的字符</li> <li>}</li> <li>//用大括号来区分变量</li> <li>//echo "$arr['name']";//用此句会报语法错误</li> <li>echo "{$arr['name']}";//此句正常,大括号内的字符将作为变量来处理</li> <li>//$str{4}在字符串的变量的后面跟上{}大括号和中括号一样都是把某个字符串变量当成数组处理</li> <li>$str = 'abcdefg';</li> <li>echo $str{4};</li> <li>?></li> </ol></div> <em onclick="copycode($('code_Kd9'));">复制代码</em> </div> </td></tr></table> <div id="comment_39988" class="cm"> </div> <div id="post_rate_div_39988"></div> <br><br>