The Very Basics
July 21, 2000
We shouldn't ignore the simple fact that PHP pages require a web server
with PHP support. At this time of writing, there are only two real
methods of using PHP with a web server: either executing the PHP
interpreter from a CGI wrapper, so that PHP runs as any CGI script
would, or integrating PHP with the Apache web server. While the CGI
wrapper method should work with a wide variety of web servers, it is
the least efficient in exeuction speed and resource consumption.
Apache+PHP is the preferred solution, although in the future we should
also see PHP integrated into other major web servers.
Unfortunately, installing and configuring your web server to properly
execute PHP pages is not really the focus of this article, and can be
a complex subject due to the variety of operating systems and web
servers that might be involved. This article will here on in assume
that your web server is already setup to serve PHP pages. If that's
not the case, you'll want to begin at the PHP web site
(http://www.php.net) to learn how
to download and install PHP for your web server. If you don't run a
web server, but rather use the services of a web host such as your
Internet Service Provider, they will need to support PHP for you.
PHP is not a client-side language. That means that browser never sees
PHP -- only the web server sees it, and executes it on-the-fly. The
browser receives only a "normal" HTML page. To achieve this, PHP code
is contained within a special tag, separating it from the other HTML on
the page:
<H2>Today's Headline:</H2><BR>
<P ALIGN="center"> <?php
your php code here
?> </P><HR>
Consider a very simple sample, where the PHP code simply outputs the
phrase "World Peace Declared":
| what the web server sees |
what the web browser receives |
<H2>Today's Headline:</H2> <P ALIGN="center"> <?php
print "World Peace Declared";
?> </P><HR>
|
<H2>Today's Headline:</H2>
<P ALIGN="center"> World Peace Declared </P><HR>
|
And of course, the web browser will render on-screen:
Today's Headline:
World Peace Declared
|
Why PHP?
Welcome to PHP
PHP Structure
|