-1

I am trying to include a CSS link in hidden input value using PHP. but it not including properly as shown in the image.

enter image description here

Code

<?php 
            $minCss='<link href="'.$bootstrap_js_link.'" rel="stylesheet">';

?>
 <input type="hidden" value="'<?php echo $minCss; ?>'" id="snippet_resource"/>
7
  • value="<?php echo $minCss; ?>" You don't need single quote Commented Apr 17, 2019 at 14:40
  • Getting this Now " id="snippet_resource"/> Commented Apr 17, 2019 at 14:41
  • 1
    You want a full <link> tag within the attribute? That's very odd, but look into htmlspecialchars then. Commented Apr 17, 2019 at 14:42
  • Why Someone giving this -ve instead of give answer! Commented Apr 17, 2019 at 14:42
  • because in your $minCss variable you have <link href="something" so you obtaine <input type="hidden" value="<link href="something"" rel="stylesheet"> id="snippet_resource"/> Commented Apr 17, 2019 at 14:42

1 Answer 1

3

You need to escape HTML entities to include your value into the attribute. You may use htmlspecialchars:

<input type="hidden" value="<?= htmlspecialchars($minCss) ?>" id="snippet_resource" />
Sign up to request clarification or add additional context in comments.

2 Comments

thanks, it worked for me... someone voted this negative... is it silly question?
@UpasanaChauhan I think it was unclear why you were doing what you were doing. It probably seemed a rather unusual thing to do, sending that string as a form input. I can't say for sure, because I was not the downvoter.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.