Reputation: 11
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.
Upvotes: 1
Views: 249
Reputation: 3118
You are returning php code inside a string. This would execute the php code but would look for the $l_continue
variable in the active php code on the page.
You therefore have to either:
echo '<div id="cp_subbtn" class="cp_subbtn">'. $l_continue .'</div>' ; }
Upvotes: 0
Reputation: 712
Try this
if ( is_user_logged_in() ) {
echo '<div id="cp_subbtn" class="cp_subbtn">'.$l_continue.'</div>' ;
}
else {
echo 'You are not logged in.' ;
}
You can just concatenate string
Upvotes: 1