How do I Build a Website Using PHP?
PHP, originally called Personal Home Page, was an HTML templating extension for the PERL computer programming language. PHP soon caught on in a big way because of its simple syntax inspired by the C programming language, and its ubiquity among open source Web servers used by most Internet Web hosts. Because of its origins as an HTML templating language, PHP makes it trivial (easy) to generate HTML, or to inject pieces of data into an existing HTML page.
Instructions
Difficulty:
Step 1
Change the extension of the HTML document in which you want to include PHP from .html to .php. For example, if your file is called index.html then you should change it to index.php.
Step 2
Open your new PHP file, then copy and paste the following code into the body of the document to display the text "Hello Joe, how are you?" as a header:
<?php
$name = "Joe";
printf("<h1>Hello %s, how are you?</h1>", $name);
?>
Step 3
Upload your PHP file to your Web server using your favorite FTP client for the upload.
Step 4
Navigate to the Web address you uploaded the file to in the previous step to see the code in action, displaying the message to "Joe."
References
Tips & Warnings
- You can mix PHP code and HTML as much you want. Sometimes PHP files will not display anything, but instead just process data, other times PHP files will be mostly HTML as in the steps above.
Article Written By L.P. Klages
L.P. Klages is an entrepreneur and software developer, concentrating on information theory, software user experience, and mathematical modeling. He has been writing about technology and the business of technology since 1999. His articles have appeared on many sites, including GameDev.net, KenSharpe.net, and eHow. Klages attended Jacksonville University in Jacksonville, Fla.