<?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; PHP</title>
	<atom:link href="http://blog.xiongchuan.org/tag/myphp/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批量删除空行&#124;wordpress迁移的艰辛</title>
		<link>http://blog.xiongchuan.org/batch-delete-blank-lines.html</link>
		<comments>http://blog.xiongchuan.org/batch-delete-blank-lines.html#comments</comments>
		<pubDate>Thu, 24 Dec 2009 08:48:03 +0000</pubDate>
		<dc:creator>Erick</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[删除空行]]></category>

		<guid isPermaLink="false">http://www.pigblog.net/?p=501</guid>
		<description><![CDATA[博客这些天一直处于死亡状态，昨天空间商帮忙把博客从浙江机房搬到河南机房了，暂时可以开通了。 Warning: Cannot modify header information &#8211; headers already sent by (output started at /*****/wp-includes/compat.php:230 头部有输出，昨天加班到比较晚，回家看《花木兰》，没去管博客，今天来公司，发现问题严重了，Google竟然抓取了页面 打开这些PHP的文件，发现下面全部都多了两行，就是php闭合标签之后多出了两个空行，造成在include 或是 require 后会有输出。 开始以为是只有几个文件是这样的，多打开几个发现，整个空间里面的php文件js,css,php都多出了两个空行，估计是华夏名网的在线文件管理器打包造成的。 因为本人对正则不熟悉，不过其实用正则替换倒不是太难，关键问题在于windows和linux下面的换行，回车符号的区别，费了不少时间研究。 虽然我知道windows下面是\r\n linux下面是\n 可是我用\r\n在windows系统上怎么也匹配不了，后来才发现我用的eclipse里面的我用的是Unix格式，换行就是\n，而不是\r\n，功夫不负苦心人哈，把代码贴出，也可以下载，有什么更好的方法，记得告诉我哈，各位！ //$path=__DIR__;//php 5.3 $path=dirname(__FILE__); function get_all_files($path,$pattern='/php$&#124;js$&#124;css$/i'){ $list = array(); foreach( glob( $path.DIRECTORY_SEPARATOR.'*') as $item ){ if( is_dir( $item ) ){ $list = array_merge( $list , get_all_files( $item,$pattern ) ); } else{ [...]]]></description>
			<content:encoded><![CDATA[<p>博客这些天一直处于死亡状态，昨天空间商帮忙把博客从浙江机房搬到河南机房了，暂时可以开通了。<br />
Warning: Cannot modify header information &#8211; headers already sent by (output started at /*****/wp-includes/compat.php:230<br />
头部有输出，昨天加班到比较晚，回家看《花木兰》，没去管博客，今天来公司，发现问题严重了，Google竟然抓取了页面<br />
<a href="http://www.pigblog.net/photos/photo/4210018847/pigblog.html" class="tt-flickr tt-flickr-Large" title="pigblog" rel="external nofollow"><img class="aligncenter" src="http://farm3.static.flickr.com/2556/4210018847_840f17f0ff_o.jpg" alt="pigblog" width="503" height="112" /></a><br />
打开这些PHP的文件，发现下面全部都多了两行，就是php闭合标签之后多出了两个空行，造成在include 或是 require 后会有输出。<br />
开始以为是只有几个文件是这样的，多打开几个发现，整个空间里面的php文件js,css,php都多出了两个空行，估计是华夏名网的在线文件管理器打包造成的。<br />
因为本人对正则不熟悉，不过其实用正则替换倒不是太难，关键问题在于windows和linux下面的换行，回车符号的区别，费了不少时间研究。<br />
虽然我知道windows下面是\r\n linux下面是\n  可是我用\r\n在windows系统上怎么也匹配不了，后来才发现我用的eclipse里面的我用的是Unix格式，换行就是\n，而不是\r\n，功夫不负苦心人哈，把代码贴出，也可以下载，有什么更好的方法，记得告诉我哈，各位！</p>
<pre name="code" class="php">
//$path=__DIR__;//php 5.3
$path=dirname(__FILE__);
function get_all_files($path,$pattern='/php$|js$|css$/i'){
    $list = array();
    foreach( glob( $path.DIRECTORY_SEPARATOR.'*') as $item ){
        if( is_dir( $item ) ){
         $list = array_merge( $list , get_all_files( $item,$pattern ) );
        }
        else{
            if(preg_match($pattern,$item)){
                $list[] = $item;
        	}
        }
    }
    return $list;
}
$list=get_all_files($path,'/php$/i');
foreach($list as $v){
$str=file_get_contents($v);
//var_dump($str);
$str=preg_replace("/\?>\s*$/i",'?>',$str);
//var_dump($str);
file_put_contents($v,$str);
}
header('Content-Type:text/html;Charset=utf-8');
echo "删除空白完成，Have a good time!";
echo "<a href="/index.php" >回首页</a>";
</pre>
<p><a href="http://www.pigblog.net/removespace.rar" rel="external nofollow">点这里下载文件</a><br />
解压后放到空间的根目录下面，会遍历所有子目录，并删除末尾的空行。</p>
<h4  class="entry-title">Related Posts</h4><ul class="related_post"><li><a href="http://blog.xiongchuan.org/blog-move-to-us.html" title="终于下了决心，把博客从国内移到国外了">终于下了决心，把博客从国内移到国外了</a></li><li><a href="http://blog.xiongchuan.org/blog-back.html" title="博客归来，更简洁了">博客归来，更简洁了</a></li><li><a href="http://blog.xiongchuan.org/flickr-photo-album-for-wordpress.html" title="Flickr Photo Album for WordPress|wp 相册">Flickr Photo Album for WordPress|wp 相册</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><li><a href="http://blog.xiongchuan.org/add-author-name-for-wordpress.html" title="给博客加个作者|wordpress作者函数">给博客加个作者|wordpress作者函数</a></li><li><a href="http://blog.xiongchuan.org/change-blog-program-to-wordpress.html" title="换博客啦">换博客啦</a></li><li><a href="http://blog.xiongchuan.org/php-braces-description.html" title="PHP的大括号，详解">PHP的大括号，详解</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.xiongchuan.org/batch-delete-blank-lines.html/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>CentOS 5.3搭建Apache2.2.4+Mysql5.1.4+PHP5.3服务器</title>
		<link>http://blog.xiongchuan.org/centos-5-3-apache2-mysql5-php-5-3-server.html</link>
		<comments>http://blog.xiongchuan.org/centos-5-3-apache2-mysql5-php-5-3-server.html#comments</comments>
		<pubDate>Sun, 08 Nov 2009 06:37:29 +0000</pubDate>
		<dc:creator>Erick</dc:creator>
				<category><![CDATA[Linux相关]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[apache]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[服务器]]></category>

		<guid isPermaLink="false">http://www.pigblog.net/?p=381</guid>
		<description><![CDATA[留着，仅供自己下次安装用。都是在网上找的方法，只是给组合了下。 (温馨提示:如果你复制的安装过程，可能有类似这样的错误: configure: warning: /usr/local/php:: invalid host type &#8230; configure: error: can only configure for one host and one target at a time 我写的是&#8211;with-前面是两个-，但是wp经过了处理变成一个-了，所以你在记事本里面把-替换成两个-就行了 ) 1、使用 yum 程序安装所需开发包（以下为标准的 RPM 包名称） # yum install gcc gcc-c++ gcc-g77 flex bison autoconf automake bzip2-devel zlib-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel # 这里我们将编译GD所必须的一些小软件比如libpng,libtiff,freetype,libjpeg等先用RPM的方式一并安装好，避免手动编译浪费时间，同时也能避免很多错误，这几个小软件的编译很麻烦。这几个小软件编译错误了，GD当然安装不了，php5的编译当然也没戏了。所以我们抓大放小，对这些小牛鬼蛇神采取快速简洁的方式进行安装。并且对服务器的性能也不能产生什么影响。 2、源码编译安装所需包 (Source) (1) GD2 # [...]]]></description>
			<content:encoded><![CDATA[<p>留着，仅供自己下次安装用。都是在网上找的方法，只是给组合了下。<br />
<span style="color: #ff0000;">(温馨提示:如果你复制的安装过程，可能有类似这样的错误:<br />
configure: warning: /usr/local/php:: invalid host type<br />
&#8230;<br />
configure: error: can only configure for one host and one target at a time<br />
<span style="color: #000000;">我写的是<span style="color: #ff0000;">&#8211;with-</span>前面是<span style="color: #ff0000;">两个-</span>，但是wp经过了处理变成<span style="color: #ff0000;">一个-</span>了，所以你在记事本里面把<span style="color: #ff0000;">-</span>替换成<span style="color: #ff0000;">两个-</span>就行了</span><br />
)</span></p>
<p>1、使用 yum 程序安装所需开发包（以下为标准的 RPM 包名称）<br />
# yum install gcc gcc-c++ gcc-g77 flex bison autoconf automake bzip2-devel zlib-devel ncurses-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel pam-devel</p>
<p># 这里我们将编译GD所必须的一些小软件比如libpng,libtiff,freetype,libjpeg等先用RPM的方式一并安装好，避免手动编译浪费时间，同时也能避免很多错误，这几个小软件的编译很麻烦。这几个小软件编译错误了，GD当然安装不了，php5的编译当然也没戏了。所以我们抓大放小，对这些小牛鬼蛇神采取快速简洁的方式进行安装。并且对服务器的性能也不能产生什么影响。</p>
<p>2、源码编译安装所需包 (Source)<br />
(1) GD2<br />
# cd /usr/local/src<br />
# wget http://www.boutell.com/gd/http/gd-2.0.33.tar.gz<br />
# tar xzvf gd-2.0.33.tar.gz<br />
# cd gd-2.0.33<br />
# ./configure &#8211;prefix=/usr/local/gd2 &#8211;mandir=/usr/share/man //./configure 配置。<br />
# make //make 是用来编译的，它从 Makefile 中读取指令，然后编译。<br />
# make install //make install 是用来安装的，它也从 Makefile 中读取指令，安装到指定的位置。</p>
<p>(2) Apache 日志截断程序<br />
# cd /usr/local/src<br />
# wget http://cronolog.org/download/cronolog-1.6.2.tar.gz<br />
# tar xzvf cronolog-1.6.2.tar.gz<br />
# cd cronolog-1.6.2<br />
# ./configure &#8211;prefix=/usr/local/cronolog<br />
# make<br />
# make install</p>
<p>(3) libxml 库程序<br />
# cd /usr/local/src<br />
# wget http://ftp.gnome.org/pub/gnome/sources/libxml2/2.6/libxml2-2.6.26.tar.gz<br />
# tar zxvf libxml2-2.6.26.tar.gz<br />
# cd libxml2-2.6.26<br />
# ./configure &#8211;prefix=/usr/local/libxml2<br />
# make<br />
# make install<br />
<span id="more-381"></span><br />
接下来进入正题，建议安装顺序Mysql,Apache,PHP<br />
3、本来想尝试用编译源码的方法安装Mysql，可是官主的5.1.4没有，就下载了5.1.3的，可是尝试装到非默认路径怎么都是出错，没办法就用了5.1.4的按照解压包里的INSTALL的提示，一步步安装到了/usr/local/mysql，挺简单。<br />
# useradd mysql //添加 mysql 用户<br />
# cd /usr/local/mysql<br />
# ./bin/mysql_install_db &#8211;user=mysql<br />
# chown -R root:mysql . //设置权限，注意后面有一个 &#8220;.&#8221;<br />
# chown -R mysql /var/lib/mysql //设置 mysql 目录权限<br />
# chgrp -R mysql . //注意后面有一个 &#8220;.&#8221;<br />
# cp share/mysql/my-medium.cnf /etc/my.cnf<br />
# cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld //开机自动启动 mysql。<br />
# chmod 755 /etc/rc.d/init.d/mysqld<br />
# chkconfig &#8211;add mysqld</p>
<p>4、编译安装 Apache2.24<br />
这个最简单了，基本不会有错误发生。<br />
# tar zxvf httpd-2.2.4.tar.gz<br />
# cd httpd-2.2.4<br />
依次安装apr和apr-util（这两个文件夹在httpd-2.2.4/srclib/里面，如下操作）</p>
<p># cd srclib/apr<br />
# ./configure &#8211;prefix=/usr/local/apr &#8211;enable-threads &#8211;enable-other-child USE=ipv6<br />
# make &amp;&amp; make install</p>
<p># cd ../apr-util<br />
# ./configure &#8211;prefix=/usr/local/apr-util &#8211;with-apr=/usr/local/apr/ &#8211;with-mysql=/usr/local/mysql<br />
# make &amp;&amp; make install</p>
<p>yum install openssl-devel.x86_64</p>
<p>cd /usr/local/src/httpd-2.2.4<br />
./configure &#8211;prefix=/usr/local/apache2 &#8211;enable-mods-shared=all &#8211;enable-deflate=shared &#8211;with-mysql=/usr/local/mysql &#8211;enable-cache &#8211;enable-file-cache &#8211;enable-mem-cache &#8211;enable-disk-cache &#8211;enable-static-support &#8211;enable-static-htpasswd &#8211;enable-static-htdigest &#8211;enable-static-rotatelogs &#8211;enable-static-logresolve &#8211;enable-static-htdbm &#8211;enable-static-ab &#8211;enable-static-checkgid &#8211;disable-cgid &#8211;disable-cgi &#8211;with-mpm=worker &#8211;with-apr=/usr/local/apr/ &#8211;with-apr-util=/usr/local/apr-util/ &#8211;enable-ssl &#8211;with-ssl=/usr/include/openssl</p>
<p># make<br />
# make install<br />
# echo &#8216;/usr/local/apache2/bin/apachectl start &#8216; &gt;&gt; /etc/rc.local //将 apachectl 的调用加入到你的系统启动文件中。</p>
<p>注解：<br />
./configure //配置源代码树<br />
&#8211;prefix=/usr/local/apache2 //体系无关文件的顶级安装目录PREFIX ，也就Apache的安装目录。<br />
&#8211;enable-module=so //打开 so 模块，so 模块是用来提 DSO 支持的 apache 核心模块<br />
&#8211;enable-mods-shared=all //编译全部的模板，对于不需要我们可以在httpd.conf去掉。<br />
&#8211;enable-cache //支持缓存<br />
&#8211;enable-file-cache //支持文件缓存<br />
&#8211;enable-mem-cache //支持记忆缓存<br />
&#8211;enable-disk-cache //支持磁盘缓存<br />
&#8211;enable-static-support //支持静态连接(默认为动态连接)<br />
&#8211;enable-static-htpasswd //使用静态连接编译 htpasswd &#8211; 管理用于基本认证的用户文件<br />
&#8211;enable-static-htdigest //使用静态连接编译 htdigest &#8211; 管理用于摘要认证的用户文件<br />
&#8211;enable-static-rotatelogs //使用静态连接编译 rotatelogs &#8211; 滚动 Apache 日志的管道日志程序<br />
&#8211;enable-static-logresolve //使用静态连接编译 logresolve &#8211; 解析 Apache 日志中的IP地址为主机名<br />
&#8211;enable-static-htdbm //使用静态连接编译 htdbm &#8211; 操作 DBM 密码数据库<br />
&#8211;enable-static-ab //使用静态连接编译 ab &#8211; Apache HTTP 服务器性能测试工具<br />
&#8211;enable-static-checkgid //使用静态连接编译 checkgid<br />
&#8211;disable-cgid //禁止用一个外部 CGI 守护进程执行CGI脚本<br />
&#8211;disable-cgi //禁止编译 CGI 版本的 PHP<br />
&#8211;with-mpm=worker // 让apache以worker方式运行<br />
&#8211;enable-ssl // 编译 ssl模块。</p>
<p>将apache设置成开机自启动:</p>
<p>在/etc/rc.d/rc.local文件中加入一行<br />
/usr/local/apache2/bin/apachectl start<br />
这样每次重新启动系统以后,apache也会随系统一起启动.</p>
<p>或者<br />
# cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd<br />
然后 vi /etc/rc.d/init.d/httpd 添加(#!/bin/sh下面)<br />
# chkconfig: 2345 10 90<br />
# description: Activates/Deactivates Apache Web Server<br />
最后，运行chkconfig把Apache添加到系统的启动服务组里面：<br />
# chkconfig &#8211;add httpd<br />
# chkconfig httpd on</p>
<p>5、编译安装php5.3<br />
下载curl 安装到/usr/loca/curl<br />
./configure &#8211;prefix=/usr/local/php &#8211;with-apxs2=/usr/local/apache2/bin/apxs &#8211;with-zlib-dir &#8211;with-bz2 &#8211;with-tiff-dir &#8211;with-libxml-dir=/usr/local/libxml2 &#8211;with-gd=/usr/local/gd2 &#8211;with-freetype-dir &#8211;with-jpeg-dir &#8211;with-png-dir &#8211;with-ttf &#8211;enable-mbstring &#8211;with-mysql=/usr/local/mysql &#8211;with-mysqli=/usr/local/mysql/bin/mysql_config &#8211;with-config-file-path=/etc &#8211;with-iconv &#8211;disable-ipv6 &#8211;enable-static &#8211;enable-maintainer-zts &#8211;enable-memory-limit &#8211;enable-zend-multibyte &#8211;enable-inline-optimization  &#8211;enable-sockets &#8211;enable-soap &#8211;with-openssl &#8211;with-curl=/usr/local/curl</p>
<p># make</p>
<p># make install</p>
<p># cp php.ini-recommended /etc/php.ini</p>
<p>6、整合apache 与php<br />
# vi /usr/local/apache2/conf/httpd.conf<br />
在最后一行加上：<br />
AddType application/x-httpd-php .php</p>
<p>查找：(设置 WEB 默认文件)<br />
DirectoryIndex index.html<br />
替换为：<br />
DirectoryIndex index.php index.html index.htm //在 WEB 目录不到默认文件，httpd 就会执行 /var/www/error/noindex.html</p>
<p>找到这一段：<br />
# AllowOverride controls what directives may be placed in .htaccess files.<br />
# It can be &#8220;All&#8221;, &#8220;None&#8221;, or any combination of the keywords:<br />
# Options FileInfo AuthConfig Limit<br />
#<br />
AllowOverride none</p>
<p>更改为AllowOverride all<br />
允许apache rewrite</p>
<p># 监听443端口,支持https连接<br />
取消注释 httpd.conf 中的 Include conf/extra/httpd-ssl.conf</p>
<p>保存httpd.conf，退出。</p>
<p># /usr/local/apache2/bin/apachectl restart //重启 Apache</p>
<p>以上就完成了，因为我用到的东西比较简单，所以这是最基本的安装了。</p>
<h4  class="entry-title">Related Posts</h4><ul class="related_post"><li><a href="http://blog.xiongchuan.org/mysql-error-1045-28000-access-denied-for-user-rootlocalhost.html" title="Mysql ERROR 1045 (28000): Access denied for user &#8216;root&#8217;@'localhost&#8217;">Mysql ERROR 1045 (28000): Access denied for user &#8216;root&#8217;@'localhost&#8217;</a></li><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/cant-find-messagefile-resolve.html" title="MySQL Can&#8217;t find messagefile,解决方法">MySQL Can&#8217;t find messagefile,解决方法</a></li><li><a href="http://blog.xiongchuan.org/mysql-find-and-delete-duplicate-records.html" title="mysql 查找重复记录 删除重复记录">mysql 查找重复记录 删除重复记录</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><li><a href="http://blog.xiongchuan.org/centos-eclipse-gbk-encoding.html" title="CentOS下eclipse支持GBK编码">CentOS下eclipse支持GBK编码</a></li><li><a href="http://blog.xiongchuan.org/dual-system-boot-grub-resolve.html" title="双系统开机进入GRUB的解决办法">双系统开机进入GRUB的解决办法</a></li><li><a href="http://blog.xiongchuan.org/centos-5-3-filezilla-ftp.html" title="CentOS5.3安装Filezilla FTP软件">CentOS5.3安装Filezilla FTP软件</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.xiongchuan.org/centos-5-3-apache2-mysql5-php-5-3-server.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Warning: strtotime() [function.strtotime]: It is not safe to rely on the system’s timezone settings. 解决方法</title>
		<link>http://blog.xiongchuan.org/warning-strtotime-function-strtotime-it-is-not-safe-to-rely-on-the-system-timezone-settings-resolve.html</link>
		<comments>http://blog.xiongchuan.org/warning-strtotime-function-strtotime-it-is-not-safe-to-rely-on-the-system-timezone-settings-resolve.html#comments</comments>
		<pubDate>Tue, 27 Oct 2009 01:22:57 +0000</pubDate>
		<dc:creator>Erick</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.pigblog.net/?p=369</guid>
		<description><![CDATA[最终决定把PHP从5.2.11换成5.3，运行phpmyadmin的时候，就报错了。 Warning: strtotime() [function.strtotime]: It is not safe to rely on the system’s timezone settings. &#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.. 没有设置默认时区，编辑 /etc/php.ini 找到 ;date.timezone= 把分号去掉，并且在后面加上PRC，因为在中国 date.timezone=PRC 重启apache service httpd restart 前提是你把apache设置成服务 否则就是 apache_dir/bin/apache1 restart Related PostsPHP批量删除空行&#124;wordpress迁移的艰辛CentOS 5.3搭建Apache2.2.4+Mysql5.1.4+PHP5.3服务器PHP的大括号，详解]]></description>
			<content:encoded><![CDATA[<p>最终决定把PHP从5.2.11换成5.3，运行phpmyadmin的时候，就报错了。<br />
Warning: strtotime() [function.strtotime]: It is not safe to rely on the system’s timezone settings. &#8230;&#8230;&#8230;&#8230;&#8230;&#8230;..</p>
<p>没有设置默认时区，编辑<br />
/etc/php.ini<br />
找到<br />
;date.timezone=<br />
把分号去掉，并且在后面加上PRC，因为在中国<br />
date.timezone=PRC<br />
重启apache<br />
service httpd restart 前提是你把apache设置成服务 否则就是<br />
apache_dir/bin/apache1 restart</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/php-braces-description.html" title="PHP的大括号，详解">PHP的大括号，详解</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://blog.xiongchuan.org/warning-strtotime-function-strtotime-it-is-not-safe-to-rely-on-the-system-timezone-settings-resolve.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<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>

