Put this in a file "a.php" and execute it. It works just fine:
$p = popen('xclip -i -selection clipboard', 'w');
fwrite($p, 'Hello Word');
"xclip -i -selection clipboard > /dev/null" should fix it
xclip doesn't close the STDOUT.
related to: this questions answer