How to Return a Stored Value in Inner text using php -


php code:

$name = 'click here';  echo '<a href="http://example.net/some.php" class="menu">$name</a>';  

here expecting 'click here' output is:

$name 

the php manual addresses accurately:

note: unlike double-quoted , heredoc syntaxes, variables , escape sequences special characters will not expanded when occur in single quoted strings.

to solve issue, use either 1 of these solutions:

echo "<a href=\"http://example.net/some.php\" class=\"menu\">$name</a>";   echo '<a href="http://example.net/some.php" class="menu">'.$name.'</a>';  <a href="http://example.net/some.php" class="menu"> <?php echo $name; ?> </a> 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -