Use of single and double quotes within an echo

1

I would like to know how I can do this correctly:

echo "<div class='table-row nocomp' id='t1' onclick='getTask1('t1','https://asd.com',5);'>"

The problem, as you can see, is here: 't1','https://asd.com',5 where I'm using single quotes within other single quotes, but I can not do it with the others because the echo is using them.

How could I do it? Can someone correct me?

Thank you.

    
asked by ByBrayanYT - Tops y más 23.10.2018 в 19:07
source

3 answers

3

Simply scan them

echo "<div class='table-row nocomp' id='t1' onclick=\"getTask1('t1','https://asd.com',5);\">"

Any character can escape by putting an inverted diagonal in front, even to escape the inverted diagonal, an inverted diagonal is necessary

    
answered by 23.10.2018 / 19:12
source
0

Try placing the echo in single quotes, and replacing the others with doubles

    
answered by 23.10.2018 в 19:10
0

Try this

echo '<div class="table-row nocomp" id="t1" onclick="getTask1("t1","https://asd.com",5);>'
    
answered by 23.10.2018 в 19:10