PHP 5.3 命名空间规则深层应用

在第一部分中我们介绍了PHP命名空间的用途和namespace关键字,在这篇文章中我们将介绍一下use命令的使用以及PHP如何解析命名空间的名字的。 为了便于对比,我定义了两个几乎一样的代码块,只有命名空间的名字不同。 lib1.php lib2.php 开始之前先要理解几个PHP命名空间相关术语。 ◆完全限定名称(Fully-qualified name) 任何PHP代码都可以引用完全限定名...

read more..

PHP 5.3 中的命名空间

命名空间是PHP 5.3中最重要的变化,对于C#和Java开发人员对这个词语非常熟悉了,他们终于可以更好地改变PHP应用程序的结构了。 为什么我们需要命名空间? 随着你的PHP代码库的增长,对之前定义的函数和类名进行修改时风险也更高了,当你试图增加第三方组件或插件时问题更严重,如果存在两个或两个以上的代码集实现了一个“Database”和“User”类会怎么样? 直到目前,唯一的解决办法是使用长的类/函数名,例如Wo...

read more..

用Gearman实现PHP的分布式处理(2011更新版)

本机环境:Debian6 .0+ PHP5.3.3-7+squeeze1 先安装任务分发的Job端 安装Gearman server and library最新0.20版: wget http://launchpad.net/gearmand/trunk/0.20/+download/gearmand-0.20.tar.gz tar zxf gearmand-0.20.tar.gz cd gearmand-0.20 ./configure sudo make sudo make install 中间可能会遇到些问题: 在./configure的时候,可能会出现缺少libraries的情况: checking for libevent…...

read more..

为PHP安装MongoDB(php-mongo)扩展

How to add mongo support to PHP 5 in CentOS ? If you have SSH access and root you should be able to follow the “Installing on *NIX” instructions (the RPMs are just created for convenience sake.) You can try using pecl … PECL is a repository for PHP Extensions and the mongo php driver uses that system. Here is a blog post you might find helpful … http:...

read more..

使用Ajax+PHP监视文件的上传进度

Monitoring File Uploads using Ajax and PHP 本文讲述如何通过HTML表单上传本地文件到服务器,并使用Ajax监视文件的上传情况,为用户显示上传进度条. 所需环境软件 1.PHP 5.2 2.APC 3.0.13或更高版本 3.Prototype JavaScript library (version 1.6.0)[下载] 实现步骤: 1.安装PHP的APC扩展 2.使用APC监视文件上传进度 3.编写相关的PHP类 4.创建传统的上传表单 5.扩展表单实现进度条效果 1.安装PHP的APC扩展 ...

read more..