简体   繁体   中英

PHP - Merge Two Functions

I need to merge the following two functions, but I can't seem to get the syntax right:

One:

<?php= time() > strtotime( $var = get_post_meta($post->ID, 'hub_expiry-date', true) ) ? 'expired' : '' ?>

Two:

<?php
$var = get_post_meta($post->ID, 'hub_expiry-date', true); if ($var == '') { echo ""; } else { echo 'expired'; }
?>

What is the correct way of merging these?

Thanks Zach

<?php
$var = get_post_meta($post->ID, 'hub_expiry-date', true);
if ( !empty($var) && time() > strtotime($var) ) {
    echo 'expired';
}
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM