PHP SPL笔记
这几天,我在学习PHP语言中的SPL
。
这个东西应该属于PHP中的高级内容,看上去很复杂,但是非常有用,所以我做了长篇笔记。不然记不住,以后要用的时候,还是要从头学起。
由于这是供自己参考的笔记,不是教程,所以写得比较简单,没有多解释。但是我想,如果你是一个熟练的PHP5程序员,应该足以看懂下面的材料,而且会发现它很有用。现在除此之外,网上根本没有任何深入的SPL中文介绍。
================
PHP SPL笔记
目录
第一部分 简介
1. 什么是SPL?
2. 什么是Iterator?
第二部分 SPL Interfaces
3. Iterator界面
4. ArrayAccess界面
5. IteratorAggregate界面
6. RecursiveIterator界面
7. SeekableIterator界面
8. Countable界面
第三部分 SPL Classes
9. SPL的内置类
10. DirectoryIterator类
11. ArrayObject类
12. ArrayIterator类
13. RecursiveArrayIterator类和RecursiveIteratorIterator类
14. FilterIterator类
15. SimpleXMLIterator类
16. CachingIterator类
17. LimitIterator类
18. SplFileObject类
第一部 简介
1. 什么是SPL?
SPL是Standard PHP Library(PHP标准库)的缩写。
根据官方定义,它是“a collection of interfaces and classes that are meant to solve
standard
problems”。但是,目前在使用中,SPL更多地被看作是一种使object(物体)模仿array(数组)行为的interfaces和classes。
2. 什么是Iterator?
SPL的核心概念就是Iterator。这指的是一种Design Pattern,根据《Design
Patterns》一书的定义,Iterator的作用是“provide an object which traverses some aggregate
structure, abstracting away assumptions about the implementation of that
structure.”
wikipedia中说,"an iterator is an object which allows a programmer to traverse
through all the elements of a collection, regardless of its specific
implementation".……"the iterator pattern is a design pattern in which iterators
are used to access the elements of an aggregate object sequentially without
exposing its underlying representation".
通俗地说,Iterator能够使许多不同的数据结构,都能有统一的操作界面,比如一个数据库的结果集、同一个目录中的文件集、或者一个文本中每一行构成的集合。
如
相关文档:
升华提供终身免费ASP+access PHP+mysql虚拟主机
一:升华网络科技有限公司,与升华同在站长终身免费空间扶持计划.
1、尊敬的用户您好,也许您还在为每年一交的空间费用发愁,也许您想获得一个更优质的空间却不想投入太多,从现在起 这些问题将迎刃而解→升华网络←与升华同在站长扶持计划全面启动。
2、没有注册公司 ......
php文件
<?php
mysql_connect("localhost","","");
mysql_query("set names 'gb2312'");
mysql_select_db("shop");
$sqlstr="select * from goods";
require 'smarty/libs/Smarty.class.php';
$smarty = new Smarty;//设置各个目录的路径,这里是安装的重点
$smarty->template_dir ="smarty/templates/templa ......
PHP 版本各异,已经停止升级开发的有 4.0 系列的 4.4.x,但现在还有部分生产环境在跑这个版本,需要继续维护代码。PHP 5.0 系列是现在开发和应用的主流版本,有 5.1.x 和 5.2.x 系列。PHP 6.0 目前还是试用版本,用 PHP 开发软件产品的人现在可以预先作兼容性测试。
PHP 支持的数据 ......
一、登陆
1.进入linux
2.用户名: root
3.口令:123456
4.mysql 用户名 root 密码 123456
二、启动mysql与apache服务
1.启动mysq数据库:/usr/local/mysql/bin/./mysqld_safe --user=mysql &
2.停止mysql数据库:/usr/local/mysql/bin/mysqladmin -u root -p shutdown
3.启动apache: /usr/local/apache2/bin/./ap ......
1 echo();2 print();3 die();4 printf();5 sprintf();6 print_r();7 var_dump();
1 echo()
可以同时输出多个字符串,可以多个参数,并不需要圆括号,无返回值。
2 print()
只可以同时输出一个字符串,一个参数,需要圆括号,有返回值,当其执行失败时返flase .print 的用法和C语 ......