I want to copy some text sent by browser to clipboard after making changes using PHP and I can do that with PHP installed via AMPPS or XAMPP but when I try it with PHP which comes by default on Sierra I'm neither getting any error message nor the text is getting copied to clipboard.
This is the code I'm using
shell_exec("echo 'Any random text' | tr -d '\n' | pbcopy");
I tried changing permissions of PHP file, ensured that code works in terminal. I tried giving absolute paths like
shell_exec("/bin/echo '$text ' | tr -d '\n' | /usr/bin/pbcopy");
I ensured safe mode is not enabled because I get output "_www" for this code
echo shell_exec("whoami");
Still I cannot copy the text. Out of limitations I have to use only default PHP in sierra. Can anyone please help me with this issue.