| PHP, originally derived from Personal Home Page Tools, now stands for PHP: Hypertext Preprocessor, which the PHP FAQ describes as a "recursive acronym." PHP is an alternative to Microsoft's Active Server Page (ASP) technology. As with ASP, the PHP script is embedded within a Web page along with its HTML. Before the page is sent to a user that has requested it, the Web server calls PHP to interpret and perform the operations called for in the PHP script.
An HTML page that includes a PHP script is typically given a file name suffix of ".php" ".php3," or ".phtml". Like ASP, PHP can be thought of as "dynamic HTML pages," since content will vary based on the results of interpreting the script.
Since it's a preprocessor, it runs on the remote web
server and processes the webpages before they are sent
to the browser. This makes it a so-called server-side
scripting language. The fact that it runs on the server
has several benefits, and some drawbacks. Let's take
the benefits first:
On the server you can have access to
things like a database. This means that you can make
a script that sorts through large amounts of data, without
the client having to download them first.
It's only the output from the script that is sent to
the client, not the script itself. That means that you
can make the script invisible from the end-user. That
makes PHP-scripts browser-neutral; they don't depend
on some capability of the browser. It also means that
you don't have to worry that someone else can steal
your carefully crafted script. It's not like when you
make a JavaScript --- everybody is able to read it in
the source of the webpage. It has to be this way with
client-side scripting, or else the client would be unable
to get the source of the script, and therefore unable
to do any scripting.
You can make your own programs for use in your scripts.
You could implement part of the script in C, and then
call the program from your script to make it run faster.
PHP is a parsed language, meaning that there are no
compiled binaries. Every time someone requests a page
with PHP-code, the parser looks through the page and
executes any PHP-statements it might find. Fortunately
this is a very fast process, but you might want to speed
things up if you have a very complicated script.
When you make a C-program, you compile
the source and then run the resulting binary. This makes
PHP slower than an equivalent C-program.
As I said, there are also some drawbacks:
By executing everything on the server,
you put more strain on it. With many concurrent requests,
and large complex scripts, the server might not be able
to handle it. But this isn't a real concern because
the parser in PHP is so quick. And if your server still
can't cope with the number of visitors, then you should
be able to generate some revenue from banners on your
site, and then pay for a bigger server!
The pages can't do anything themselves --- you need
the server to do the magic. This means that the pages
will lose some of their functionality if your visitors
decide to save them to their computer.
You could of course still put some JavaScript
in your pages. This is a very powerful combination between
server- and client-side scripting. You could use PHP
to fetch some values from a database, and then setup
your variables in the JavaScript with these values.
I find that PHP offers a site a more
flexibility and is more dynamic than HTML can offer
on its own.
Some Background Information
PHP is actually a rather simple language,
despite its great powers. It's a very young language,
so the developers have had the chance to learn from
previous language's mistakes and implement their strengths.
Much of the syntax is borrowed from C. This is reflected
in the different conditional statements, the loop-structures,
the Boolean operators, and the assignment of variables.
Since C is probably the most common programming language
today, this should make PHP easy to pick up. Even if
you don't have any previous experience with C you should
be able to learn it quickly. One can
just apply the techniques learned from PHP when
one programs in C. Of course this is only true as long
as you only write simple programs in C, since C is a
"real" programming language, suitable for
writing operating-systems in or the like.
But another thing that makes PHP easy
to learn is it's relaxed way of dealing with the types
of variables. Its very simple: you don't have to think
of the types of variables at all! If you assign a number
to a variable, then it just works. When you later try
to output the variable to the browser it also just works.
PHP takes care of converting the variable from an integer-type
to a string-type, on the fly and automatically. To make
matters even simpler, you don't even declare your variables
--- you just assign a value to them, and then they are
ready.
Because PHP is meant to be used with
webpages it has a lot of functions to deal with text.
Generally you can say that PHP is specially designed
to deal with webpages, and doing so quickly and efficiently.
Because of that most of the built-in functions are simple
and straightforward to use.
Being web-oriented, PHP also contains
all the functions you'll need to do things on the Internet.
There are functions for connecting to remote webservers,
checking mail via POP3 or IMAP, or url encoding strings
to protect special characters.
The World Wide Wonderland (as they say) will contain a huge
amount of PHP related informatiom (see the Resources section) in case you
get stuck! Feel free to contact me if you want any additional information or want to correct or add anything to this document.
|