php函数用于真假条件

问题描述 投票:-1回答:1

我有PHP函数和Iam试图在真假条件下使用它。

function tribe_is_past_event( $event = null ) {

        if ( is_null( $event ) ) {
            global $post;
            $event = $post;
        }
        // Check if event has passed
        $gmt_offset = ( get_option( 'gmt_offset' ) >= '0' ) ? ' +' . get_option( 'gmt_offset' ) : ' ' . get_option( 'gmt_offset' );
        $gmt_offset = str_replace( array( '.25', '.5', '.75' ), array( ':15', ':30', ':45' ), $gmt_offset );

        if ( strtotime( tribe_get_end_date( $event, false, 'Y-m-d G:i' ) . $gmt_offset ) <= time() ) {
            return true;
        }

        return false;

    }

这是我的功能。如果此功能存在或为真,我试图做什么然后打印没有其他可用的其他付款选项

像这样。但这只是第一个条件。否则条件不起作用。

<?php 
      if(function_exists('tribe_is_past_event')){
      echo "no option";
      }
       else{?>

                 <form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post" id="buy_ticket">
                    <input type="hidden" name="cmd" value="_xclick">
                    <input type="hidden" name="business" value="[email protected]">
                    <input type="hidden" name="currency_code" value="USD">
                    <input type="hidden" name="item_name" value="<?php the_title()?>">
                    <input type="hidden" name="amount" value="<?php echo str_replace("$", "",tribe_get_cost( null, true )) ?>">
                    <input type="hidden" name="return" value="<?= home_url();?>">
                    <input type="hidden" name="cancel_return"     value="<?php global $wp;
echo home_url( $wp->request )?>">
                    <div class="buy_btn">
                    <input type="image" src="" border="0" name="submit" alt="Buy Tickets">
                    </div>
                </form>
       <?php }?>
php function
1个回答
0
投票

嗨,谢谢你的种类支持解决方案就是这个。谢谢你们的支持

<?php 
     if (tribe_is_past_event()){
      echo "no option";
      }
       else{?>

                 <form name="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post" id="buy_ticket">
                    <input type="hidden" name="cmd" value="_xclick">
                    <input type="hidden" name="business" value="[email protected]">
                    <input type="hidden" name="currency_code" value="USD">
                    <input type="hidden" name="item_name" value="<?php the_title()?>">
                    <input type="hidden" name="amount" value="<?php echo str_replace("$", "",tribe_get_cost( null, true )) ?>">
                    <input type="hidden" name="return" value="<?= home_url();?>">
                    <input type="hidden" name="cancel_return"     value="<?php global $wp;
echo home_url( $wp->request )?>">
                    <div class="buy_btn">
                    <input type="image" src="" border="0" name="submit" alt="Buy Tickets">
                    </div>
                </form>
       <?php }?>
© www.soinside.com 2019 - 2024. All rights reserved.