This is a html paragraph
echo 'This is some php txt';
You will have to name your files with a php extension for the server to recognize them as PHP files and have the PHP parser look for the <?php tags in your file and parse them as php.
Hope this helps.
A bit more on the PHP Extension:
You can also use mod_rewrite in Apache to allow any extension to be parsed as php if you want. (google mod_rewrite) or you could change the mime type associated with an extension on your server (Apache). Apache than assigns a handler for that mime type, and if you associate the extension with the mime type "application/x-httpd-php" it will be parsed as php.
If you are using the include() function in php, it doesn't matter what extension the file is, it will be parsed as php.
Another problem is if the server is set up to parse xml files then your <? will be treated as the beginning of <?xml .
So its considered proper form to use <?php ... ?> instead since it should always work on servers with php support.
If you have a script that has alot of shorthand php syntax, and find out it doesnt work on your server, or a server you supplied your php to, then you can use a regex expression to convert your shorthand to the regular syntax.
If you change the extension from html to php on an existing site, you will be starting all over again with the search engines. That becomes a URL change. If you have an existing site, you probably want to set up the server to run html files through the php interpreter, which is what digital-ether is referring to.
Sorry alpha2006. digital-ether is also correctly stating the best practices method for PHP coding. If transportability is an issue, you should always use php in the opening tag. It avoids a range of problems.
If you are on a Unix or Linux server and can use the .htaccess file, you can set the server to parse html extensions just like php. You just need to add the following to your .htaccess file. Be aware that this may not work if your hosting company does not allow changes to the .htaccess file.
AddType application/x-httpd-php .html .htm
If your hosting company allows this change, all files with an html or htm extension will be treated as if they had a php extension.
If you don't want to reconfigure Apache, you can set up 301 redirects from your htm files to .php. Some search engines (I think most of them) will keep your page rank and transfer the records to the new location. Don't use 302 redirects, as that's not the same thing.
301 - Moved Permanently
302 - Moved Temporarily
(This is something that can be done through most webhost's setup.)