This is part of a collection of information about computer programming languages,
which is part of my web collection of information.
Php is a programming language which is interpreted on a web server, which produces HTML as the output of the Php script. The main idea of using php is to be able to produce dynamic web pages, or pages with more up-to-date information. Plain old HTML is considered static, or information that does not change unless someone updates the HTML.
This write-up assumes that you are familiar with HTML and you can take care of uploading your work to the web server and all that jazz. This is just an introduction of how you can go about learning the basics and some of the more advanced functions of php, and how it will help you produce more relevant, up-to-date web pages for your visitors.
One big advantage of php is that you can jump in and out of Php, within HTML. To start using php, type this
<?php followed by your Php code. There are other ways to escape to php, but this is the most reliable. (the other methods are not always supported by the web server. If asp tags are enabled, you can use
<% and if short tags are enabled, you can use
<? and to close the opening tag (that is, to stop using php, and go back to HTML), you can use
Now that you know how to tell the web server that what follows is php, (
<?php), how can you output some information? Php has two easy ways to output text, number, contents of variables or results of functions (among other things). First, you can type
print "Hello, world."; or
echo "Hi there!";. Echo is technically a php operator, and print is a function that has a lot of useful formatting options to help format strings. For my purposes, I will use
echo for most of the output in this document. (hey, it saves typing one letter).
Ok, here is a sample file that contains a combination of HTML and Php and creates an HTML document that reads "Hi there!".
<html> <head> <title>Hi there!</title> </head> <body> <h1><?php echo "Hi there!"; ?></h1> </body> </html>
Contine browsing the collection of information about some programming languages,
or return to my web collection of information.