Search code examples
phpjavascriptconfirmation

using javascript quotes in php code


i'm having some trouble using javasript in php code, I'm confused in using double quotes and single quotes.

echo '<a href="shop.php?buy=1" onclick="return confirm("Are you sure you want to delete?")">Delete</a>';

or how to do the above code in php ?.

Thanks


Solution

  • use this code

    echo '<a href="shop.php?buy=1" onclick="return confirm(\'Are you sure you want to delete?\')">Delete</a>';
    

    you have to escape the quotes.

    http://viper-7.com/F6uI0L