Can't use function return value in write context
I am using a ternary function just to check if a value is empty or not.But its returning a fatal error
Fatal error: Can't use function return value in write context in /home/sommelie/food.toogoodtogo.hu/wp-content/themes/...../woocommerce/config.woocommerce.php on line 551
$shipping = !empty(get_post_meta( $restaurant_id, 'delivery_charge', true )) ? get_post_meta( $restaurant_id, 'delivery_charge', true ) : '0.00';
What could be a possible error?is there any error, i don't think so because it works on my server but not this current one.
I am not understanding why it's happening.This is a part of a wordpress theme.
I had some trouble when trying to use empty
with a function call
empty(someFunction());
You should declare a variable to store the post medatata. Or your code will call 2 times the get_post_meta()
if the first call return something. It isn't needed :)
$postMetadata = get_post_meta( $restaurant_id, 'delivery_charge', true );
$shipping = !empty($postMetadata) ? $postMetadata : '0.00';
链接地址: http://www.djcxy.com/p/58440.html
上一篇: “<<< ST”在PHP中意味着什么?
下一篇: 在写入上下文中不能使用函数返回值