-1

I do not know if the title left doubts, but I will show the code that is generating the button, and I need the variable to be surrounded by quotation marks like this: onclick = "anything (value)" -> NOW

onclick = "anything ('value')" -> HOW I WANT

$btn = '<button type="button" onclick="button('.$id.')" class="btn blue-madison btn-sm" style="margin:0px;">Gerenciar</button>';
VitorZF
  • 15
  • 3

1 Answers1

0

The following is a double quote enclosed string which allows you to place single quotes inside, and use double quotes by escaping them like \". In addition, variables are replaced with their values in double quote enclosed strings.

$btn = "<button type=\"button\" onclick=\"button('$id')\" class=\"btn blue-madison btn-sm\" style=\"margin:0px;\">Gerenciar</button>";
bhooks
  • 409
  • 5
  • 16