1. configure the PHP file directory as the script language for server instructions. The PHP program is placed in a directory that a server can visit. Generally, you can correct the httpd of Apache. conj configuration, for example, in this file: Alias/test/
1. configure the php file directory
As the script language for server instructions, the PHP program is placed in a directory that a server can visit. generally, Apache httpd can be corrected. conj configuration, for example, the following sentence in this file:
Alias/test/'d:/phpwebsite/php/', enter "http: // localhost/test/PHP file name" in the browser to visit d: the php file under/phpwebsite/php/. it can be seen that this line is just a different number for the directory where the php file is stored.
You can also specify the DocumentRoot path to get the directory where the server files are stored. conj finds the following two lines. The path can be specified at will, and your php file can be stored in this directory. the server can also run them, such as "http: // localhost/PHP file name ".
Generally, it is better to put the php file in the same place, which facilitates management, while other files are placed in another place.
DocumentRoot 'C:/usr/bin/html /'
2. index files in the server directory
In httpd. conj, there is a line:
DirectoryIndex index.html
The specified directory is index.html. when you access a directory, the server will search for index.html. if it does not exist, the server will display the list of all files in the directory. by default, the opened files can be changed to other files, such as index. php3 and so on, but maybe we have many directories, whether they store images, text and other materials, or the directories that store php files or other files, we do not expect users to see the file list in the directory, in httpd. a. htacess file, which generates a directory index file. for example, we use a WordPad to create a directory index file. htacess file:
#. Htacess #
DirectoryIndex error_open.php
Create an error warning file:
# Error_open.php #
Here, error_open.php is the Permission error warning file, which stores the 2 files in all protected directories. when the user wants to open the directory, he will take the initiative to fulfill error_open.php and display an error warning.
3. Directory deletion clever implementation
We know that there is a rename () function in PHP4 for/win32 that supports renaming directories/files, such:
Rename (oldpath, newpath) // oldpath is the original path of the file or directory;
// Newpath is the new defined path;
To change the oldpath to newpath.
PHP4 does not have a function to delete directories/FILES. how can this function be deleted? We know that php. ini has a line for configuring the temporary file directory for HTTP upload control:
Upload_tmp_dir =;
PHP4 supports the configuration of this temporary directory (PHP3 is not supported). when the upload control is complete, the temporary directory is automatically cleared. well, we can use it to delete files/directories, for example, set upload_tmp_dir = 'd:/phpwebsite/php/tmp /';
To delete a directory path, perform the following:
Tmp = 'd:/phpwebsite/php/tmp /;'
Rename (path, tmp)
?>
After the file or directory path is renamed to tmp, all the files/directories under the tmp directory are automatically cleared, and the deletion control is completed.
4. quickly create a MySql database table
PHP and MySql databases have been fully integrated. on the webpage, for example, for new users who publish works in forums or book houses, we need to write their comments online into the database, create a data table for the user in the corresponding database. Creating a new MySQL empty database under win32 is simple. you only need to create a folder under the "/mysql/data/" directory, such as '/usrinfo. To add a new table to the database, you can use the following program: