Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

single quote inside double quote in php

Tags:

php

<input id="myID" onClick="CheckAll('A','B');" />

In the project,the above code need to be put into String(see 2nd snippet). However, the CheckAll() is already inside the single quote. If two parameters are inside Single quote in checkAll() like 2nd code snippet, the checkAll() won't work.

How to fix the 2nd code snippet?

Thanks in advance and any help will be really appreciated!

$string ="<input id='myID' onClick='CheckAll('A','B');' />"
like image 865
Acubi Avatar asked Feb 04 '26 06:02

Acubi


1 Answers

You can use backslash:

$string ="<input id=\"myID\" onClick=\"CheckAll('A','B');\" />"
like image 154
Zebra Avatar answered Feb 06 '26 20:02

Zebra