<?php$value = 'abc"def';echo "<button onclick=\"func(" . htmlspecialchars(json_encode($value)) . ")\"><button>";
Standard input is empty
<button onclick="func("abc\"def")"><button>
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!