Reputation: 1082
I am trying to add a custom link to the href tag using the following code
<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
<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'>
Upvotes: 1
Views: 1781
Reputation: 1712
You can do with single quotes of 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.'">'; ?>">
Upvotes: 0
Reputation: 1259
,Change to single quotes on the outside: Also, if the html attribute is double has a quote inside it needs to be escaped using: "
<?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:
<?='<link href="'.$bootstrap_css_link.'">'?>
See this stack overflow question for reference: How to properly escape quotes inside html attributes?
Upvotes: 2
Reputation: 21
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."\">"; ?>">
Upvotes: 2