Use of static variables in PHP for instance analysis and php instance analysis
This article describes how to use static variables in PHP. We will share this with you for your reference. The details are as follows:
1. Define static variables
Public static $ endpoint, $ accessKeyId, $ accessKeySecret, $ bucket;
2. static variable assignment
Protected function _ initialize () {self: $ endpoint = C ('oss _ endpoint'); self: $ accessKeyId = C ('oss _ ACCESS_ID '); self :: $ accessKeySecret = C ('oss _ ACCESS_KEY '); self: $ bucket = C ('oss _ TEST_BUCKET ');}
3. Use static variables
Public static function getOssClient () {try {$ ossClient = new OssClient (self ::$ accessKeyId, self :$ accessKeySecret, self ::$ endpoint, false );} catch (OssException $ e) {printf (_ FUNCTION __. "creating OssClient instance: FAILED \ n"); printf ($ e-> getMessage (). "\ n"); return null;} return $ ossClient ;}