echo "<b>Your ID</b> = ". $row['customer_id']."";
I couldn't find any way to copy the echo to the clipboard. Can you guys help me ? Thanks much.
echo "<b>Your ID</b> = ". $row['customer_id']."";
I couldn't find any way to copy the echo to the clipboard. Can you guys help me ? Thanks much.
The shortest answer; you'll have to tell the OS to do it for you by using shell_exec("echo [thing_to_copy] | [OS Copy Command]
e.g. on MacOS
, the copy to clipboard command is pbcopy
.
So in PHP we can do
shell_exec("echo 'copy-me' | pbcopy");
which will put copy-me
into the clipboard OF THE SERVER
.
PHP is a server-side language. Meaning, it runs on the server. If you run this, it'll copy the content (copy-me
in the previous example) to the server's clipboard
which might NOT be what you want.
To copy to the client's clipboard, you'll have to use Javascript because it runs on the client-side.
Edit: added a link to copy using javascript from comments
Never run or use shell_exec
or exec
without sanitization. In fact, don't run them at all using user-supplied data.