1.定义静态变量
public static $endpoint,$accessKeyId,$accessKeySecret,$bucket;
2.静态变量赋值
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.静态变量使用
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;
}
本文转自TBHacker博客园博客,原文链接:http://www.cnblogs.com/jiqing9006/p/5408182.html,如需转载请自行联系原作者