|
PHP stands for PHP: Hypertext Pre-processor.
The funny abbreviation follows the style set by
Richard Stallmann when he founded GNU (GNU's not
Unix!) As the name says, it's a pre-processor
for hypertext, which is just another word for
what most people call webpages.
Since it's a preprocessor, it runs on the remote
web server and processes the webpages before they
arrive 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. Lets 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 seeks through large amounts
of data, without the client has 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 that you 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 a someone
requests a page with PHP-code, the parser
looks through the page and executed 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 that 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 if you
start getting that many hits, then you'll
probably be able to buy yourself a bigger
server :-)
-
The pages can't do anything themselves -
you need the server to do the magic. 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.
|
|