PHP - echo with content that has double quote and single quote

2

What is the correct way to do the following echo in PHP

echo '<img class="imgfit img" src="img/evento/3-thumb.jpg" onclick="window.location.href="img/evento/3.jpg"" style="border-radius:0;" alt="">';

The dilemma I have is that when using window.location.href you have to use single or double quotes, then how can I solve the problem?

    
asked by Máxima Alekz 29.07.2016 в 22:49
source

1 answer

4

You could simply make an "escape" from the quotes of the item in question and use single quotes, as in your case:

onclick="window.location.href=\'img/evento/3.jpg\'"
    
answered by 29.07.2016 / 22:58
source