Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
关于PHP语句_Php_If Statement - Fatal编程技术网

关于PHP语句

关于PHP语句,php,if-statement,Php,If Statement,有人能帮我为这句话编代码吗 <?php if(get_post_meta($post->ID, "price", $single = true) != ""){ ?> <?php echo get_post_meta($post->ID, "price",$single = true); ?> <?php } ?> 如果我的自定义字段为空,我希望语句继续使用此代码 <?php $asin = get_post_meta($post-&g

有人能帮我为这句话编代码吗

<?php if(get_post_meta($post->ID, "price", $single = true) != ""){ ?>
<?php echo get_post_meta($post->ID, "price",$single = true); ?>
<?php } ?>

如果我的自定义字段为空,我希望语句继续使用此代码

<?php $asin = get_post_meta($post->ID, 'asin', true);
echo azon_us_price($asin);
 ?>

我想您应该这样做:

<?php
if(!empty(get_post_meta($post->ID, "price", $single = true))){ 
  echo get_post_meta($post->ID, "price",$single = true); 
} else {
  $asin = get_post_meta($post->ID, 'asin', true);
  echo azon_us_price($asin);
}
?>


hi Null,在带有价格id的post meta中,如果价格id中为空,我希望语句继续使用第二个语句并显示结果价格id$post->id是什么?