- ·上一篇文章:使用Xdebug优化你的php程序
- ·下一篇文章:PHP在Web开发领域的优势在哪?
php4和php5单态模式(Singleton Pattern)写法
单态模式(Singleton Pattern) 就是一个类Class只有一个实例存在。(Ensure a class only has one instance, and provide a global point of access to it.)
这个是php5的写法。
| 以下为引用的内容: <?php class SingletonPhp5{ static private $_instance=null; function getInstance(){ function __construct(){ } function Show(){ { |
这个是php4的写法,当然此方法在php5下也可以正常运行。
| 以下为引用的内容: class SingletonPhp4{ |
