[英]Adding custom link to href tag
I am trying to add a custom link to the href tag using the following code 我正在尝试使用以下代码向href标签添加自定义链接
<input type="text" id="bootstrap_css_link_script" aria-hidden="true"
class="offscreen form-control" value="<?php echo "<link
href='".$bootstrap_css_link."'>"; ?>">
everything is fine but I want to get the href tag in doublequote("") as shown below 一切都很好,但我想在doublequote(“”)中获得href标记,如下所示
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css">
But after executing the above code I am getting the following result 但是执行上面的代码后,我得到以下结果
<link href='//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css'>
,Change to single quotes on the outside: Also, if the html attribute is double has a quote inside it needs to be escaped using: "
,更改为单引号在外面:另外,如果HTML属性是双有报价里面需要使用转义:
"
<?php echo '<link href="'.$bootstrap_css_link.'">'; ?>
Also, you can remove echo to save a few clicks and clean up the code inside your HTML: 另外,您可以删除echo来保存一些点击,并清理HTML中的代码:
<?='<link href="'.$bootstrap_css_link.'">'?>
See this stack overflow question for reference: How to properly escape quotes inside html attributes? 请参阅此堆栈溢出问题以供参考: 如何正确转义html属性内的引号?
you have to use \\"
for escape a double quotes. So, your code should be like this 您必须使用
\\"
转义双引号。因此,您的代码应如下所示
<input type="text" id="bootstrap_css_link_script" aria-hidden="true"
class="offscreen form-control" value="<?php echo "<link
href=\"".$bootstrap_css_link."\">"; ?>">
You can do with single quotes of php 您可以用php单引号
<?php
$bootstrap_css_link="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css";
?>
<input type="text" id="bootstrap_css_link_script" aria-hidden="true class="offscreen form-control" value="<?php echo '<link href="'.$bootstrap_css_link.'">'; ?>">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.