user2805663
user2805663

Reputation:

echo <a href="#"></a> in php

how to echo anchor in php when anchor has # as its href i has search a lot in net and i havent found similar probnlem so i cant fint any possible solution to this problem.

i tried putting he # inside "''" but its not working when i just do thre regular anchor like <a href="#"></a> all characters following the # sign will become comments.

echo "<a href="#" >".$value['searchresultwhat']."</a>";

Upvotes: 2

Views: 3037

Answers (5)

Morgan O&#39;Neal
Morgan O&#39;Neal

Reputation: 1118

You can do one of these. I'm not a fan of \"

echo "<a href=\"#\">{$value['searchresultwhat']}</a>";
echo "<a href='#'>{$value['searchresultwhat']}</a>";

Complex (curly) syntax

Upvotes: 1

Shijin TR
Shijin TR

Reputation: 7768

You can try

 echo "<a href='#' >".$value['searchresultwhat']."</a>";

OR

 echo "<a href=\"#\" >".$value['searchresultwhat']."</a>";

OR

 echo '<a href="#" >'.$value['searchresultwhat'].'</a>';

OR

 <a href="#" ><?= $value['searchresultwhat'] ?></a>;

OR

 <a href="#" ><?php echo $value['searchresultwhat'] ?></a>;

Upvotes: 0

Deepu Sasidharan
Deepu Sasidharan

Reputation: 5309

Try this..

echo "<a href='#' >".$value['searchresultwhat']."</a>";

Upvotes: 0

John Robertson Nocos
John Robertson Nocos

Reputation: 1485

Add backslashes \ \ to the attribute

echo "<a href=\"#\" >".$value['searchresultwhat']."</a>";

Upvotes: 0

Jenz
Jenz

Reputation: 8369

You have to escape the double quotes. Try with

echo "<a href=\"#\">".$value['searchresultwhat']."</a>";

Upvotes: 0

Related Questions