In the project,the above code need to be put into String(see 2nd snippet). However,
Alternatively
$string = '<input id="myID" onClick="CheckAll(\'A\',\'B\');" />';
$string ="<input id='myID' onClick=\"CheckAll('A','B');\" />"
add escaping slashes
You can use backslash:
$string ="<input id=\"myID\" onClick=\"CheckAll('A','B');\" />"