To include PHP content, a web page must meet four criteria:
The page name must have a suffix of .php. If you want to use a four-letter extension, use
.phpx as the page name, where x is the version of PHP being used (for example,
You must have the page on a web server with PHP installed. (i.e. the URL must include
http://). You can install server software on your own machine for testing purposes; this server will serve only you.
<? /* opening PHP tag closing PHP tag */ ?>
This is also valid:
<?php /* opening PHP tag closing PHP tag */ ?>
The PHP code must be valid. Invalid PHP code will typically cause the page to stop displaying correctly, or not display at all.
Enjoy this piece? I invite you to follow me at twitter.com/dudleystorey to learn more.