【发布时间】:2015-04-26 00:04:59
【问题描述】:
public function store($feed)
{
switch($feed)
{
case 'full':
$coupons = json_decode(file_get_contents('path-to-json-feed'), true);
break;
case 'incremental':
$coupons = json_decode(file_get_contents('path-to-different-json-feed'), true);
break;
}
var_dump($coupons);die();
$this->Deal_model->updateAllDeals($coupons);
echo 'Coupons Updated';
}
我正在尝试为$coupons 赋值,但var_dump($coupons) 返回一个空数组。
【问题讨论】:
-
那么你的问题是?
-
如果
$feed既不是“满”也不是“增量”,那么$coupons将是空的……那么你验证过$feed的值了吗? -
对不起第一次发帖,我把它搞砸了。 $coupons 变量在 var_dumped 时返回为空数组。
-
如果我 var_dump $feed 它是一个字符串“增量”
-
@mjamieson 的 exact 输出是什么:
var_dump($feed);(从源代码中获取输出)?
标签: php variables scope switch-statement