Reputation:
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
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>";
Upvotes: 1
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
Reputation: 5309
Try this..
echo "<a href='#' >".$value['searchresultwhat']."</a>";
Upvotes: 0
Reputation: 1485
Add backslashes \ \
to the attribute
echo "<a href=\"#\" >".$value['searchresultwhat']."</a>";
Upvotes: 0
Reputation: 8369
You have to escape the double quotes. Try with
echo "<a href=\"#\">".$value['searchresultwhat']."</a>";
Upvotes: 0