PHP根据当前类型的单例模式

class Model_Table extends Zend_Db_Table_Abstract {
	private static $instances = array ();
	static function getInstance($config = array()) {
		$key = get_called_class ();
		if (! array_key_exists ( $key, self::$instances )) {
			self::$instances [$key] = new static ( $config );
		}
		return self::$instances [$key];
	}
}

 

class Pass_Table_UserIdModel extends Model_Table_Pass {
	protected $_name = 'user_id';
	protected $_primary = 'username';
	protected $_dependentTables = array (
			'Pass_Table_UserModel' 
	);
}

 

$userid = Pass_Table_UserIdModel::getInstance ();
vardump($userid);

$userid的类型就是Pass_Table_UserIdModel,关键的地方是new static($config),这个是后期静态绑定

参考:

http://php.net/manual/zh/language.oop5.late-static-bindings.php

Starting php-fpm: Failed loading /usr/lib64/php/modules/ZendDebugger.so: libcrypto.so.0.9.8: cannot open shared object file: No such file or directory

centos6 安装zenddebug 无法启动,需要给依赖库做软链,yum找到指定版本依赖库并安装都不行,就得软链过去。

[root@ares ~]# service php-fpm restart
Stopping php-fpm:                                          [  OK  ]
Starting php-fpm: Failed loading /usr/lib64/php/modules/ZendDebugger.so:  libcrypto.so.0.9.8: cannot open shared object file: No such file or directory
                                                           [  OK  ]
[root@ares ~]# ln -s /usr/lib64/libcrypto.so.1.0.0 /usr/lib64/libcrypto.so.0.9.8
[root@ares ~]# service php-fpm restart                                          
Stopping php-fpm:                                          [  OK  ]
Starting php-fpm: Failed loading /usr/lib64/php/modules/ZendDebugger.so:  libcrypto.so.0.9.8: cannot open shared object file: No such file or directory
                                                           [  OK  ]
[root@ares ~]# ln -s /usr/lib64/libcrypto.so.1.0.1e /usr/lib64/libcrypto.so.0.9.8
[root@ares ~]# service php-fpm restart                                           
Stopping php-fpm:                                          [  OK  ]
Starting php-fpm:                                          [  OK  ]
[root@ares ~]#

 

参考:

http://dvlancer.com/36-how-to-install-zend-debugger-on-centos.html

yum安装指定版本软件

比如依赖libssl.so.0.9.8

[root@ares modules]# yum provides */libssl.so.0*                   
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: ftp.sjtu.edu.cn
 * extras: mirrors.aliyun.com
 * remi: remi.kazukioishi.net
 * updates: mirrors.skyshe.cn
openssl098e-0.9.8e-18.el6_5.2.i686 : A compatibility version of a general cryptography and TLS library
Repo        : base
Matched from:
Filename    : /usr/lib/libssl.so.0.9.8e



openssl098e-0.9.8e-18.el6_5.2.x86_64 : A compatibility version of a general cryptography and TLS library
Repo        : base
Matched from:
Filename    : /usr/lib64/libssl.so.0.9.8e



openssl098e-0.9.8e-18.el6_5.2.i686 : A compatibility version of a general cryptography and TLS library
Repo        : installed
Matched from:
Filename    : /usr/lib/libssl.so.0.9.8e

然后

[root@ares modules]# yum install openssl098e-0.9.8e-18.el6_5.2.i686

 

参考:

https://www.centos.org/forums/viewtopic.php?t=22243