PHP Hypertext Preprocessor

Filed under: Reference Comments: 0

PHP is a widely-used general-purpose scripting language that is especially suited for Web development and can be embedded into HTML.

So says PHP.net, and I am willing to go with that. PHP's real strength seems to be it's ability to be used for a process called server-side scripting.

Why use PHP?

One of the major advantages of using PHP is that it allows webmasters to dynamically generate web content on-the-fly, perhaps using pre-coded chunks of HTML code or loading content from a database. Using PHP, we can perform form validation without having to rely on complex CGI scripts. PHP can be used to generate RSS feeds from our existing site content. If you can think of it, you can probably code a PHP script to run it.

Drawbacks?

Well, the biggest drawback to relying on PHP is that you need to have your site hosted on a service that not only has PHP installed (or that is willing to install it for you), but that has the correct version of PHP. Code written for PHP5 might not work on a PHP4 install, and so on...

A Word from Our Sponsors...

If you really want to learn the ins-and-outs of web design, I strongly suggest you visit the awesome folks at W3Schools.com. That site has just about everything there is to know about proper web page development. I am merely going to paraphrase some of what I learned there and elsewhere.

Okay!

File Structure

For the most part, PHP documents have the file extension, .php, although you can also use .php4, .php3, or .phtml. You can also save a PHP document as a .html file, but there is no guarantee that the PHP parser will parse your document if you do so.

Inside your PHP document, you must define the beginning and ending scope of the code you want the parser to execute. This scope is defined like so:

PHP has a solid library of usable code behind it. This library gives every budding PHP programmer a good start, and (like all OOP languages) can be extended to fit every unique need that arises

At this time, the functions that I have used most are the include and the echo functions. The include function is placed in our code where we want to insert external documents or scripts. The echo function is used to, well, echo a string out to the current document. The string will be output exactly in the location in which the echo statement occurs within the source document. These two functions alone can be used to save a lot of work on our part, and to provide feedback to our users.

I use the include function to insert the code for my document's header, footer, and navigation menu. By doing so, I save myself a lot of rewriting, copying, and pasting if I choose to update the image(s) or text in any of those parts of my pages. The echo statement is really useful when I validate my various forms, as I can give the user(s) fairly explicit directions if the form(s) fail to validate.

Do You Want to Know More...?

Check out php.net if you want to get the inside scoop. Also, I wrote up a simple tutorial for building a webpage using HTML and PHP, [ here ].

PHP Keywords

and or xor __FILE__
exception __LINE__ array() as
break case class const
continue declare default die()
do echo() else elseif
empty() enddeclare endfor endforeach
endif endswitch endwhile eval()
exit() extends for foreach
function global if include()
include_once() isset() list() new
print() require() require_once() return()
static switch unset() use
var while __FUNCTION__ __CLASS__
__METHOD__ final php_user_filter interface
implements instanceof public private
protected abstract clone try
catch throw cfunction
(PHP 4 only)
old_function
(PHP 4 only)
this final __NAMESPACE__ namespace
goto
(PHP 6 only)
__DIR__

Definitions:

Parser:

In computer technology, a parser is a program, usually part of a compiler, that receives input in the form of sequential source program instructions, interactive online commands, markup tags, or some other defined interface and breaks them up into parts (for example, the nouns (objects), verbs (methods), and their attributes or options) that can then be managed by other programming (for example, other components in a compiler). A parser may also check to see that all input has been provided that is necessary. (whatis.com)