How to automatically create a file with code in SSH?

ssh

Solution

echo "some text" > myfile.txt

Will result in a file named myfile.txt with "some text" in it.

If you already have a file on your local machine that you're trying to move to the remote machine, you could use scp.

scp /some/local/file.txt my.server.com:/some/remote/file.txt

Problem

How would I create a file in SSH with code already in it? Something along the lines of touch filename.php >> echo "thecode here" ?? Also, any SSH tips? Looking to become more efficient. You know, work smarter not harder.

Original source