首页 > 解决方案 > Show an echo function inside an echo function in a div

问题描述

I am trying to display a variable inside a php function.

This is the code:

if ( is_user_logged_in() ) {
echo '<div id="cp_subbtn" class="cp_subbtn"><?php echo $l_continue; ?></div>' ; } else { echo 'You are not logged in.' ; }

What I get is just a stylized div ( class="cp_sbbtn" ), but I have no text displayed. I am trying to figure out how to display a variable ( $l_continue) text inside an echo function, like in this case.

标签: wordpress

解决方案


尝试这个

if ( is_user_logged_in() ) { 
    echo '<div id="cp_subbtn" class="cp_subbtn">'.$l_continue.'</div>' ;
 }
 else { 
    echo 'You are not logged in.' ; 
 }

你可以只连接字符串


推荐阅读