最近遇到这样的一个问题:我在本地的操作项目环境是Wamp的,然后上传到服务空间是Linux+nginx的。在本地运行和在Wamp环境运行时,以下这个功能是完全没问题的,如图:
但是在Linux+nginx却出现了这样的情况:
实现功能的代码都是一样的,这部分代码的截图如下:
$properties_gj = get_goods_properties_gj($goods_id); // 获得高级定制商品的规格和属性
//var_dump($properties_gj);
$spe = array();
foreach ($properties_gj['spe'] as $v){
if($v['name'] == '加字'){
$spe[0] = $v;
}
if($v['name'] == '外观材质'){
$spe[1] = $v;
}
if($v['name'] == '内里材质'){
$spe[2] = $v;
}
}
//echo "
"; <br> //var_dump($spe);exit; <br> 附加:打印$properties_gj的结果 <br> array(3) { <br> ["pro"]=> <br> array(0) { <br> } <br> ["spe"]=> <br> array(3) { <br> [2]=> <br> array(3) { <br> ["attr_type"]=> <br> string(1) "1" <br> ["name"]=> <br> string(6) "加字" <br> ["values"]=> <br> array(1) { <br> [0]=> <br> array(6) { <br> ["label"]=> <br> string(12) "雕刻文字" <br> ["price"]=> <br> string(3) "200" <br> ["imgs"]=> <br> string(50) "./images/attr/c249e9ab5fb4df62753e3ce483ca2296.png" <br> ["times"]=> <br> string(1) "5" <br> ["format_price"]=> <br> string(9) "¥200.00" <br> ["id"]=> <br> string(3) "265" <br> } <br> } <br> } <br> [3]=> <br> array(3) { <br> ["attr_type"]=> <br> string(1) "1" <br> ["name"]=> <br> string(12) "外观材质" <br> ["values"]=> <br> array(1) { <br> [0]=> <br> array(6) { <br> ["label"]=> <br> string(21) "可定制任何木纹" <br> ["price"]=> <br> string(3) "500" <br> ["imgs"]=> <br> string(50) "./images/attr/8d0a35a4d338ae4acdfbe650d84026bc.png" <br> ["times"]=> <br> string(2) "15" <br> ["format_price"]=> <br> string(9) "¥500.00" <br> ["id"]=> <br> string(3) "266" <br> } <br> } <br> } <br> [4]=> <br> array(3) { <br> ["attr_type"]=> <br> string(1) "1" <br> ["name"]=> <br> string(12) "内里材质" <br> ["values"]=> <br> array(1) { <br> [0]=> <br> array(6) { <br> ["label"]=> <br> string(18) "此款不可更换" <br> ["price"]=> <br> string(0) "" <br> ["imgs"]=> <br> string(0) "" <br> ["times"]=> <br> string(1) "0" <br> ["format_price"]=> <br> string(7) "¥0.00" <br> ["id"]=> <br> string(3) "267" <br> } <br> } <br> } <br> } <br> ["lnk"]=> <br> array(0) { <br> } <br> } <br> <br> 在Wamp环境下打印$spe是有值的,但是在Linux+nginx下,打印出来是空的,怎么也进入不了if判断,如果把if判断去掉 $spe[0] = $v;$spe[1] = $v;$spe[2] = $v;(或者把if条件里面的“==”改成“=”),只获取到 的情况。对Linux+nginx,会不会配置有关,如果不该配置,有没有解决的方法,谢谢指点一下! <p> </p> <br> <h2>回复讨论(解决方案)</h2> <p class="sougouAnswer"> 你把$properties_gj 和$goods_id 打印一下看看 </p>