php命令行没有返回值,PHP没有返回值(甚至未NULL)

$reduced = is_reduced($pid);

set_sale($pid, $reduced);

echo " - " . $reduced . " - ";

因此,背后的逻辑应该是这样的: 我调用函数is_reduced()到知道,如果产品减少。通常,它应该在那里返回真或假。但我没有得到任何回报。你可以看到,我正在用变量向控制台打印变量。但我什么也没看到。甚至不是NULL!

但在控制台上,我可以看到,它得到“不减少”打印出来。所以,它也应该返回someting。因为echo后面跟着函数is_reduced(下面的代码)中的返回命令。

功能的一些信息: 一页可以有多个价格。这就是为什么我有while循环的原因。如果只有一个价格,我得到-1回到var aktueller_counter。所以,我跳进第一个部落。在那里检查是否有较低的价格,如果是,如果这个价格不是0,不是“”并且不低于-1。

正如你所看到的,它说echo其次是return。但为什么我没有得到任何NULL或任何布尔值回来?

我会很乐意帮忙! 亲切的问候!

下面的代码:

function is_reduced($pid){

$aktueller_counter = -1;

while(have_rows('product_shops', $pid)): the_row();

$aktueller_counter = $aktueller_counter + 1;

endwhile;

if($aktueller_counter == -1){

$price = get_field("product_shops_0_price", $pid);

$price_old = get_field("product_shops_0_price_old", $pid);

if($price_old < $price) {

if ($price_old != "") {

if ($price_old != 0) {

if ($price_old > -1) {

$price = null;

$price_old = null;

$aktueller_counter = null;

echo ", is \"reduced\"";

return true;

} else {

$price = null;

$price_old = null;

$aktueller_counter = null;

echo ", is NOT \"reduced\"";

return false;

}

} else {

$price = null;

$price_old = null;

$aktueller_counter = null;

echo ", is NOT \"reduced\"";

return false;

}

} else {

$price = null;

$price_old = null;

$aktueller_counter = null;

echo ", is NOT \"reduced\"";

return false;

}

} else {

$price = null;

$price_old = null;

$aktueller_counter = null;

echo ", is NOT \"reduced\"";

return false;

}

}else{

for($i = 0; $i <= $aktueller_counter; $i++){

$price = get_field("product_shops_".$i."_price", $pid);

$price_old = get_field("product_shops_".$i."_price_old", $pid);

if($price_old < $price){

if($price_old != ""){

if($price_old != 0){

if($price_old > -1) {

$price = null;

$price_old = null;

$aktueller_counter = null;

echo ", is \"reduced\"";

return true;

}

}else {

$price_old = null;

$price = null;

}

}else {

$price_old = null;

$price = null;

}

}else {

$price_old = null;

$price = null;

}

}

$price = null;

$price_old = null;

$aktueller_counter = null;

echo ", is NOT \"reduced\"";

return false;

}

}

2017-07-16

Erik

+0

当我面对其中一个问题时,我会做的就是在这里写一个'echo';'将代码从if转移到next,如果在几分钟内你会看到你的代码是如何工作的(和问题)。 –

+0

'回声'功能的工作权利? –

+0

我已经做到了“不减少”。所以,它应该是返回的东西... –

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值