Databases Reference
In-Depth Information
about the client. This means they adapt to changes in load and can handle very large
numbers of requests on modest hardware. The stateless model is ideal for fast, one-off
communications where you want to retrieve a document or run one script.
At the same time, lack of state makes application development harder. If you need state,
then you have to add it programmatically so that it can be restored with subsequent
requests. For example, if you want to lead a user through a series of steps, ensure they
don't access certain parts of the web site without logging in, or make sure they only
run a script once, then you need state. PHP provides tools for this purpose—embedded
in the sessions functions and features discussed in Chapter 14—but they need to be
used carefully. Adding state to web database applications isn't straightforward, and it
must carefully follow rules so that it's robust and secure.
Web Server Index Files
The browser may simply request a directory rather than a specific filename. For exam-
ple, the address http://www.invyhome.com/ corresponds to the document root direc-
tory, while the address http://www.invyhome.com/shop/ corresponds to the the shop
directory under the document root. When the web server receives such a request, it
searches for an index file in the directory. The index file is typically used as the starting
point for a web site or web application and has the filename index.html (for plain
HTML), index.php (for a PHP script), or index.pl (for a Perl script). If there is no index
file present in the directory, the web server returns a listing of all files in the directory,
or, if the server has been configured for greater security, tells the browser that access
to the directory contents is denied.
You can check what filenames your Apache server treats as index files by looking inside
the Apache configuration file and searching for the DirectoryIndex directive. For ex-
ample, you might see:
DirectoryIndex default.htm Default.htm index.cgi index.htm index.html index.php
index.php3 index.php4 index.php5 index.phtml index.pl index.xml
If there are multiple index files in a directory, the server will use the one that appears
first in its DirectoryIndex list.
If the requested address doesn't end with a forward slash symbol ( / ), the web server
has to first check if the address corresponds to a file or a directory. For example, for
the address http://www.invyhome.com/shop , the server needs to check whether it should
return the file shop in the document root, or the index file in the shop directory under
the document root.
Introducing PHP
PHP is a scripting language that is designed to be embedded into the HTML markup
used for web pages; it can be used for other purposes, but that's outside the scope of
 
Search WWH ::




Custom Search