The two most commonly used techniques for constructing a polyglot program are to make liberal use of languages that use different characters for comments and to redefine various tokens as others in different languages. Often good use is made of syntax quirks. These are demonstrated in this public domain polyglot written in ANSI C, PHP and bash:

The term is sometimes applied to programs that are valid in more than one language, but do not strictly perform the same function in each. One use for this form is a file that runs as a DOS batch file, then re-runs itself in Perl: