-1

I am trying to get a link to open to a blank web viewer page using an echo statement that pulls two variables to create the link.

The following shows my last attempt.

echo "<a target="_blank" href=$link>$media</a>";

I'm getting a syntax error but have gone blank as to where it is.

insertusernamehere
  • 23,204
  • 9
  • 87
  • 126

1 Answers1

-1

You should escape double quotes. Also, as a rule of thumb, use htmlspecialchars when composing html attributes:

echo sprintf('<a target="_blank" href="%s">%s</a>', htmlspecialchars($link), $media);

vbarbarosh
  • 3,502
  • 4
  • 33
  • 43