首页 > phper

php 自动加载函数 __autoload()

PHP在魔术函数__autoload()方法出现以前,如果你要在一个程序文件中实例化100个对象,那么你必须用include或者require包含进来100个类文件,或者你把这100个类定义在同一个类文件中——相信这个文件一定会非常大。

阅读全文

php对unicode转utf-8编码

如果只是unicode转utf-8编码的算法,网上到处都是了,不过很多人也是你抄我,我抄你,根本就不理解why和do,本文除了给出最简单的php对unicode转utf-8编码函数之外,也深入讨论了这两种编码的关系,理解好了会发现网上一些旧的东西,是严重多余兼过期的,因为从utf-8流行开始到现在,早已经由原来六字节可变编码到实际完全居于unicode(UCS-2)的稳定阶段。

阅读全文

php 一行行读取文本文件

Example Usage

This method of iterating over the file and seeking to the line number works well and is memory efficient, but it would be nice to have PHP do the work for us. PHP provides the SPL File Object which will do exactly what is required.

阅读全文