1. Configure the PHP file directory
as a scripting language for server-side interpretation, PHP programs are placed in a directory that a server can access. You can generally configure Apache by modifying the Httpd.conj, such as the one we have in the file:
alias/test/"d:/phpwebsite/php/", then enter at the browser end: "http://localhost/ test/+php file name "You can access the PHP file under d:/phpwebsite/php/, which is simply an alias for the directory where the php files are stored.
Second, you can also specify the DocumentRoot path to the directory where the server files are located, the following two lines in the Httpd.conj, where the path can be arbitrarily specified, your PHP files can also be placed in the directory, the server can also run them, such as "http ://localhost/+php filename ".
Generally, it's better to keep your PHP files in one place, and you can manage them more easily, while others are in another place.
DocumentRoot "c:/usr/bin/html/"
2. Index file for server-side directories
In Httpd.conj, there is one line:
DirectoryIndex index.html
The row specifies that the directory defaults to open file as index.html, and when a directory is accessed, the server automatically finds index.html and, if not, displays a list of all the files in the directory, and the default open file can be changed to something else. such as index.php3 and so on, but perhaps we have a lot of directories, whether it is to store pictures, text, and other information, or to store PHP files or other files directory, we do not want users to see the directory in the list of files, in the Httpd.conj A. htacess file is specified in the file, which produces a directory index file, for example, we use WordPad to create a. htacess file:
#. Htacess #
DirectoryIndex error_open.php
Create an error warning file again:
# error_open.php #
The error_open.php is a permission error warning file that places the 2 files under all protected directories and automatically turns to execute error_open.php when the user attempts to open the directory, displaying an error warning.
3. Directory Deletion clever implementation
We know that there is a rename () function in PHP4 For/win32 that can support renaming a directory/file, such as:
Rename (OldPath, NewPath)//OldPath as the original path of the file or directory;
NewPath is the new defined path;
Realize the OldPath renamed to NewPath.
There is no function to delete the directory/file in the PHP4, how to delete it? As we know, there is a row in php.ini for the temporary file directory configuration line used to complete the HTTP upload operation:
upload_tmp_dir=;
PHP4 support the configuration of the temporary directory (PHP3 not supported), when the upload operation is completed, automatically empty the temporary directory, OK, with it we can skillfully implement file/directory deletion, such as setting: Upload_tmp_dir= "d:/phpwebsite/php/tmp/";
To delete a directory path, perform:
Tmp= "d:/phpwebsite/php/tmp/;"
Rename (path, TMP)
?>
After the file or directory path is renamed TMP, all files/directories under the TMP directory are automatically cleared and the deletion is completed.
4. Quickly establish MySQL database table
PHP and MySQL database to achieve a perfect combination, on the Web page, such as in the Forum or bookstore published works of new users, we want to write his message online to the database, often in the corresponding database for the user to create a new data table. Win32 to create a new MySQL empty database is very simple, as long as the "/mysql/data/" directory to create a folder, such as: "/usrinfo/", you can. Adding a new table to the library can be accomplished by using the following program:
# connect.mysql--Connection Database #
Connection = mysql_connect ();
mysql_select_db ("Usrinfo", connection);
?>
# make.php--establishes the following data table with user name as table name #
Call Connect.mysql
Require ("Connect.mysql");
Check for data tables with user name as table name?
query= "SELECT COUNT (*) from Usrname";
Result=mysql_db_query (query);
Does not exist then creates, if exists is the old user;
if (! Result) {
mysql_query ("
CREATE TABLE Usrname (
ID tinyint (6),
Title text,
Body Longtext,
Dateof date;
Timeof time;
) or Die (Mysql_error ());
}
To insert a new data section into a datasheet
?>