-3

I have this PHP code who send an URL as argument to a JS function :

<?php
$url="www.google.com";
echo '<input type="submit" name="btnfone" onclick="window.open('.$url.')" class="btn-style2" value="Viewmap"/>';
?>

When I test it, nothing append. But if I change the URL with an integer

$url=1234;

Then the argument is interpreted.

What's the solution ?

SachaDee
  • 9,245
  • 3
  • 23
  • 33

1 Answers1

2

Just add quotes and escape.

onclick="window.open(\''.$url.'\')"