Archives by Tag 'PHP'

编译PHP5缺t1lib包解决方案

By Symphony - Last updated: Sunday, March 29, 2009

遇到这个报错: configure: error: Your t1lib distribution is not installed correctly. Please reinstall it. 以下是解决步骤: 1. 下载t1lib-5.1.2.tar.gz 2. 解决依赖关系:apt-get build-dep t1lib 3. 安装:./configure & make without_doc & make install 4. 编译php5 时在./configure后加上 –with-t1lib=/usr/local/share/t1lib。再次编译就能通过了。

在 Ubuntu 上使用 apt-get 安装配置 Apache2.2 + PHP5.2 + MySQL5.0

By Symphony - Last updated: Thursday, March 19, 2009

安装以下这些包 apache2 php5-mysql libapache2-mod-php5 mysql-server libapache2-mod-auth-mysql php5-cli (中间会提示输入MySQL密码) 参考:LAMP服务器的配置

Constructor 主题缺少title的bug

By Symphony - Last updated: Monday, March 9, 2009

一直觉得这款主题很切合我的性格,可是发现它的title不能正常输出博客标题。稍微研究了一下,其实只要编辑 wp-content/themes/constructor/header.php 这个文件,将 <?php wp_title(”); ?> 这一行替换为 <?php bloginfo(‘name’); ?> <?php if ( is_single() ) { ?> » Blog Archive <?php } ?> <?php wp_title(); ?>

调试技巧

By Symphony - Last updated: Wednesday, July 2, 2008

# tail -f /var/log/apache2/error.log 运行 apache2 错误日志 tail -n 1000 /var/log/apache2/error.log apache2错误日志的位置,显示 1000 行 /var/log/syslog 系统错误日志的位置

count和sizeof的效率对比

By Symphony - Last updated: Monday, June 9, 2008

今日有某篇文章对指出sizeof()的效率比count()的效率要高,甚至说在for循环中使用sizeof的效率要高于在循环外预赋值的使用sizeof。 我测了一遍,觉得他的测试方法有问题。问题在于程序仅运行了一次就下结论,没有排除偶然性。以下是我的测试代码: <?php $arrTest = array_fill( 0 , 10000 , 999 ); function test1( $arrTest ) { $startTime = microtime( true ); $size = count( $arrTest ); for ( $i = 0 ; $i < $size ; $i++ ); return ( microtime( true ) - $startTime ); } function test2( $arrTest ) { $startTime = microtime( true ); for ( [...]

[代码规范]PHP中声明变量的好处

By Symphony - Last updated: Sunday, June 8, 2008

一、避免被自己的代码污染,产生非语法错误。 例如: for( $i = 0 ; $i < 100 ; ++$i ) { $a[$i] = $i; } isset( $a ) ? var_dump( $a ) : var_dump( ‘$a is not defined!’ ); 结果: array(100) { [0]=> int(0) [1]=> int(1) [2]=> int(2) [3]=> int(3) [4]=> int(4) [5]=> int(5) [6]=> int(6) [7]=> int(7) [8]=> int(8) [9]=> int(9) [...]

PHP递归调用

By Symphony - Last updated: Sunday, June 8, 2008

function daddslashes($string, $force = 0) { !defined( ‘MAGIC_QUOTES_GPC’ ) && define( ‘MAGIC_QUOTES_GPC’ , get_magic_quotes_gpc() ); if(!MAGIC_QUOTES_GPC || $force) { if(is_array($string)) { foreach($string as $key => $val) { $string[$key] = daddslashes($val, $force); } } else { $string = addslashes($string); } } return $string; } 红色部分写得很帅,绿色的部分我不赞同 改为 defined( ‘MAGIC_QUOTES_GPC’ ) or define( ‘MAGIC_QUOTES_GPC’ , get_magic_quotes_gpc() ); 和 [...]

巧妙的使用可变变量,让代码更简洁直观

By Symphony - Last updated: Sunday, June 8, 2008

foreach( array( ‘_COOKIE’ , ‘_POST’ , ‘_GET’ ) as $_request ) { foreach( $$_request as $_key => $_value ) { … } }