I want to display this command echo "<?php phpinfo(); ?>"
using div
tag and copy it by pressing the copy
button. I try this,
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div type="button" id="content">echo "<? phpinfo(); ?>"</div>
<button onclick="copyToClipboard()">Copy</button>
<script>
function copyToClipboard() {
var copyText = document.getElementById("content").innerHTML;
navigator.clipboard.writeText(copyText).then(() => {
console.log(copyText);
});
}
</script>
</body>
</html>
but it only display echo ""
and in console I see echo "<!--? phpinfo(); ?-->"
Then, I use entity number like this echo "<? phpinfo(); ?>"
or entity name like this echo "<? phpinfo(); ?>"
it displays correctly but when I press the copy
button, I get the string with entity name or number which is not that I want.
How can I solve this?