Posted in PHP onDecember 01, 2016
本文实例讲述了PHP中静态变量的使用方法。分享给大家供大家参考,具体如下:
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; }
希望本文所述对大家PHP程序设计有所帮助。
PHP中静态变量的使用方法实例分析
- Author -
牛逼的霍啸林声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@