Php 如何设置函数为空时的值?
在Wordpress的Php 如何设置函数为空时的值?,php,replace,null,Php,Replace,Null,在Wordpress的functions.php中,我创建了一个占位符,用于Events Manager Pro。(基本上,它可以在我的博客上获得活动的票价。) 它工作,但我需要一个额外的是,我似乎无法让它工作 我需要添加一个条件: If #_PRICE (this function) = empty (null) then set the value to '0.00' 目前的代码是: <?php function em_event_output_placeholder_tax($re
functions.php
中,我创建了一个占位符,用于Events Manager Pro。(基本上,它可以在我的博客上获得活动的票价。)
它工作,但我需要一个额外的是,我似乎无法让它工作
我需要添加一个条件:
If #_PRICE (this function) = empty (null) then set the value to '0.00'
目前的代码是:
<?php
function em_event_output_placeholder_tax($replace, $EM_Event, $result){
switch( $result ){
case '#_PRICE':
$replace = '';
foreach( $EM_Event->get_tickets()->tickets as $EM_Ticket ){
$replace .= number_format($EM_Ticket->get_price(), 2, '.', '');
}
break;
}
return $replace;
}
add_filter('em_event_output_placeholder','em_event_output_placeholder_tax',1,3);
?>
请帮忙