This article describes how static variables are used in PHP. Share to everyone for your reference, as follows:
1. Defining 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. Static variable use
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;}
The above is the use of static variables in PHP example analysis of the content, more relevant content please pay attention to topic.alibabacloud.com (www.php.cn)!