您好,这是我想将变量放入数组
的代码 class NewTest extends BaseExample {
public function render() {
$startDate = $this->getNow();
$endDate = $this->getNow();
$optParams = array(
'metric' => array('EARNINGS'),
'useTimezoneReporting' => true,
'filter' => 'DOMAIN_NAME==' .$sub. ',
);
我已经尝试了' .$sub.'
和$ sub但是它不起作用
答案 0 :(得分:0)
轻微的语法错误 - 只需删除最终的. '
class NewTest extends BaseExample {
public function render() {
$startDate = $this->getNow();
$endDate = $this->getNow();
$optParams = array(
'metric' => array('EARNINGS'),
'useTimezoneReporting' => true,
'filter' => 'DOMAIN_NAME==' . $sub,
);
}
}
答案 1 :(得分:0)
缺少'
'filter' => 'DOMAIN_NAME==' .$sub. '',
因为它没用,所以应该更好
'filter' => 'DOMAIN_NAME==' .$sub,
答案 2 :(得分:0)
删除'
class NewTest extends BaseExample {
public function render() {
$startDate = $this->getNow();
$endDate = $this->getNow();
$optParams = array(
'metric' => array('EARNINGS'),
'useTimezoneReporting' => true,
'filter' => 'DOMAIN_NAME==' .$sub,
);