Variable parsing is performed only in double quotes . You can use string concatenation or, what I find more readable, printf [docs] :
printf('<a href= "#" onClick="showDetails(\'%s\');">%s</a> ', $node, $insert);
The best way would be not echo HTML at all, but embed PHP in HTML:
<?php $node = $name->item(0)->nodeValue; $insert = "cubicle" . $node; ?> <td> <a href= "#" onClick="showDetails('<?php echo $node;?>');"> <?php echo $insert; ?> <br /> </a> </td>
You need to think less about quotes and debugging your HTML code is easier.
Note. If $node represents a number, you don't need quotation marks around the argument.
Felix kling
source share