‘PHP’目录下的所有文章

为PHP5安装PEAR

2 条评论 十二月 26th, 2009

最近在学习PHP的PEAR(PHP Extension and Application Repository PHP扩展与应用库),测试软件我都首先在FreeBSD上安装,因为早已习惯与其软件维护的简便。
#cd /usr/ports/devel/pear
#make install clean
执行安装后提示当前PHP没有运行在命令行模式下,无法安装
#cd /usr/ports/lang/php5
#make config

PHP 遍历数组的方法

没有评论 七月 7th, 2009

1. foreach()
foreach()是一个用来遍历数组中数据的最简单有效的方法。
#example1:

< ?php
$colors = array('red','blue','green','yellow');
foreach ($colors as $color) {
echo "Do you like $color? <br />";
}
?>

显示结果:
Do you like red?
Do you like blue?
Do you like green?
Do you like yellow?

Mac OS X 上的PHP开发环境

4 条评论 六月 28th, 2009

终究还是抵挡不住Apple的诱惑,入手Macbook。在这个从未接触过的Mac OS X上,开始捣鼓我的个人开发环境设置。
一、配置终端
我一直都喜欢用终端的,FreeBSD下用Tcsh,Ubuntu和Mac OS X下也尝试下bash。先查看终端的配置信息:
$echo $SHELL
/bin/bash
$echo $PS1
\h:\W \u\$ –这个4个参数分别是hostname,工作目录,用户名和美元符$,管理员级的配置文件是/etc/bashrc。
现在先选择终端的偏好设置,我将主题改到Pro并将字体改为Monaco 14pt,这个主题基本上是黑色背景+20%左右的透明度,视觉效果很不错。然后在shell设定标签中,选择当shell退出时关闭窗口。我选择编辑~/.bash_profile

Joomla安装注意事项

没有评论 十一月 21st, 2008

Joomla版本: Joomla_1.5.8-Stable-Full_Package
Joomla的安装与Wordpress相比还是有一些不同的,虽然目前已经非常简单,但是还是有要注意的地方。
1. 我发现configuration.php-dist不能预先复制为configuration.php,安装前一有configuration.php 这个文件存在,主页的访问链接就无法打开了。还是在安装完毕后进行操作比较合适。安装完成时会提供一段配置文件给你写入configuration.php并上传到joomla根目录

时间函数问题-设置PHP5的时区

没有评论 三月 17th, 2008

<?php
$currtime=time();
$currtimestr=strftime ("%H:%M:%S ",$currtime);
echo "The time is : ".$currtimestr;
print (strftime("%A"));
?>

在PHP5中,不能和PHP4一样使用date() , time() 等时间函数正确地取得本地时间, 不同的代码在不同的OS里会产生不同的结果。解决办法,为PHP5设置统一的时区:
编辑 “php.ini”,找到以下行修改:
date.timezone = PRC   //PRC代表中华人民共和国

PHP 扩展:mbstring

没有评论 三月 6th, 2008

因为最小化安装的PHP,很多扩展没有启用,在登陆phpMyAdmin时得到一个警告:
The mbstring PHP extension was not found and you seem to be using a multibyte charset. Without the mbstring extension phpMyAdmin is unable to split strings correctly and it may result in unexpected results.
我发现 http://www.php.net/mbstring 上有介绍说:
mbstring provides multibyte specific string functions that help you deal with multibyte encodings in PHP.
Note: If you are connecting to [...]

Page 1 of 212