【发布时间】:2017-09-23 00:20:56
【问题描述】:
嗨,我当前的函数是这样的......我想知道如何使用 const apiKey 作为数组。以及如何将'key'=> self::apiKey 用作'key'=> self::apiKey[rand(0,1)] 等。请帮助我。
const apiKey = 'api_key_ods000doo123';
public function counter_params($video_ID, $part) {
$params = array(
'id' => $video_ID,
'key' => self::apiKey,
'part' => $part
);
$result = self::Connect($params);
//print_r($params);
return $result;
}
【问题讨论】:
-
所以将你的 const 定义为数组。
-
报错....
-
然后发布您遇到的错误。不知道问题出在哪里,我们无能为力。
-
你的 PHP 版本是多少?好像我记得 const 数组并不总是可用...
-
@Don'tPanic Const 数组自 php5.6 起可用
标签: php arrays function class constants