简体   繁体   中英

include php code inside an echo

I want to add this

<?php wp_nav_menu( array( 'theme_location' => 'top-navigation-menu' ) ); ?>

between this div,

<div class="right"></div>

of below code. This whole HTML code is currently outputs by <?php echo ?>

This is what I used,

<?php
echo '<div class="top-box-2">
    <div class="container">
        <div class="left">
            Search bar
        </div>
        <div class="right"><?php wp_nav_menu( array( 'theme_location' => 'top-navigation-menu' ) ); ?></div>
    </div>
</div>'; ?>

But it doesn't work when I put the php code inside the <div></div>

<?php
echo '<div class="top-box-2">
    <div class="container">
        <div class="left">
            Search bar
        </div>
        <div class="right">' . wp_nav_menu( array( 'theme_location' => 'top-navigation-menu' ) ) . '</div>
    </div>
</div>'; ?>

Have a look at String Operators in the PHP Documentation.

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