I need echo something like this:
echo "<a href="#">$some['variable']</a>
How can I escape []
brackets to echo variable in link?
echo "<a href='#'>" . $some['variable'] . "</a>";
or
echo "<a href=\"#\">" . $some['variable'] . "</a>";
or
echo "<a href='#'>{$some['variable']}</a>";
尝试这种方式:
echo "<a href='#'>{$some['variable']}</a>";
My favorite:
echo "<a href='#'>$some[variable]</a>";
The only one that should ever be used
<a href="#"><?=$some['variable']?></a>
or (preferred)
<a href="#">{{ some.variable }}</a>
A note for the fellow experts: If you think that some of these codes are improper, consult documentation first.
有2种好的方法:
echo '<a href="#">'.$some['variable'].'</a>';
echo "<a href=\\"#\\">$some['variable']</a>";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.