0

I am trying to create a tag with contact. but, it does not working for me. here is the required output, that i want.

<a href="javascript:void(0)" onClick="myfunction('1','0','Unpaid','tr_1','td_1')">Link</a>

i want this type of a tag using php code

<?php
$id="1";
$status = "unpaid";
$str = "0";
$trid = "tr_1";
$tdid = "td_1";

echo $a = '<a href="javascript:void(0)" onClick="myfunction({$id})" class="btn btn-sucess">link</a>';
?>
Ahmad Hassan
  • 371
  • 4
  • 22
Jydipsinh Parmar
  • 484
  • 5
  • 14

1 Answers1

1

You should use outer double quotes, and escape inner double quotes.

<?php
$id="1";
$status = "unpaid";
$str = "0";
$trid = "tr_1";
$tdid = "td_1";

echo $a = "<a href=\"javascript:void(0)\" onClick=\"myfunction({$id})\" class=\"btn btn-sucess\">link</a>";
?>

PHP doesn't interpret variables in single quotes.