You can copy javascript code but you can't copy PHP code because its executing inside the server.
In other words javascripts are client side scripts, they run in your browser. But PHP is a server side script. Which run inside the server and output dynamic HTML pages to your browser.