简体   繁体   中英

Inserting echo inside echo on php

I try to call an echo inside the shortcode. The line of code is like this:

<?php echo do_shortcode('[audio src="<?php echo $audio; ?>"]'); ?>

The complete code is like this:

<?php if(get_post_meta($post->ID, '_format_audio_embed', true)!=''){ 
    $audio = get_post_meta($post->ID, '_format_audio_embed', true);
} else {
    $audio = '';    
}
?></h1>  

<?php echo do_shortcode('[audio src="<?php echo $audio; ?>"]'); ?>

My code did not work. Am I missing something?

Why are you using PHP inside PHP? Try to concat:

<?php echo do_shortcode('[audio src="'.$audio.'"]'); ?>

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