PHP设计模式笔记二:面向对象 -- Rango韩老师 http://www.imooc.com/learn/236

SPL标准库的使用php

  SPL是用于解决典型问题(standard problems)的一组接口与类的集合。数组

  一、SPL提供了不少数据结构类,如SplStack、SqlQueue、SqlHeap、SplFixedArray等数据结构

  实例代码以下:函数

    a、栈3d

    

    b、队列对象

    

    c、定长数组blog

    

  二、PHP链式操做的实现接口

    index.php队列

    

    IMooc/Database.php字符串

     

  三、PHP魔术方法

    a、__get\__set:对象属性的管理

      index.php

      

      Object.php

      

      output  :  string(19) "IMooc\Object::__get" hello

    b、__call\callStatic:控制对象方法的调用

      index.php

      

      Object.php

      

      output:

        string(4) "test" array(2) { [0]=> string(5) "hello" [1]=> int(123) }
        string(8) "sayHello" array(2) { [0]=> string(8) "helloJiu" [1]=> string(8) "helloPHP" }

    c、__toString():将一个PHP对象转化成字符串

    d、__invoke():将一个对象当成函数调用时,会调用这个函数

      index.php

      

      Object.php

      

      output:

        IMooc\Object        string(8) "helloJiu"

相关文章
相关标签/搜索