Install.php simple production
recently compiled some source code, such as summer CMS article management system, summer PHP message book, summer amendment and deletion program, summer voting system, and so on. It is for the convenience of PHP new friends to learn to use, so direct export of the MySQL database, put it in the root directory, in fact, this is not a very good experience for beginners, many new PHP friends do not know how to import MySQL database, no, and later to write a special article about "how to" The article that uses tools to import the MySQL database.
if we use open source PHP program, we will feel downloaded source code is very simple, because there is an installation source file, through this source, automatic MySQL database import and program configuration installation, even do not understand PHP program, installation is also very simple, for the use of learning is also very simple, for learning In the case of PHP, this is a very necessary function, before Ben Bo wrote a simple installer that briefly describes the principles of the PHP installer.
downloaded PHP source code, usually in the root directory there will be a install.php file, this is the PHP source of the installation file, if you want to install PHP source code, usually through the "your web site /install.php" path to install, in the installation process, will be required to fill in the MySQL username and secret Code, etc., can be installed successfully as required.
in fact, we can understand the principle of the installation of the PHP program in the install.php installation panel. Through the install.php file, we will require us to fill in the host address, the MySQL username, the MySQL password, and the MySQL database, which are basically all these. As for the more complex, it may require some writing to write. Document what, we first look at the simplest principle, we know the basic information required to fill in the installation, it is not difficult to think of, these are to generate a configuration config.php similar files, through this config.php configuration file, you can connect the MySQL database, and then through the PHP SQL The MySQL table is completed by the statement, and the simplest install.php installer is created.
below look at the simple source code for a install.php installation file:
[code]
.lt; HTML xmlns=.quot; http://www.w3.org/1999/xhtml.quot; Tent-Type.quot; content=.quot; text/html; charset=utf-8.quot; /.gt;
.lt; title.gt; PHP installation small program.Lt; /title.gt;
host address:.Lt; input type=.quot; text.quot; name=.quot; host.quot; value=.quot. .quot; password.quot; name=.quot; psw.quot; value=.quot;.Quot;.Gt;.Lt; br.gt;
,
. .lt; /form.gt;
.lt; PHP
else
{
$lockfile =.Quot; 3;! =.quot;.Quot;)
{
$host=$_POST.#91;'host'.#93;
$user=$_POST.#91;'user'.#93;
$psw=$_POST.#91;'psw'.#93; {} / > Install install.lock.quot;
}
$conn=mysql_connect ($host, $user, $psw);
if ($conn)
{
}; Create TABLE `blog`.`blog` (
`id` INT (4) NOT NULL AUTO_INCREMENT,
`con`) P_db, $conn);
mysql_query ($sql_create_db, $conn);
mysql_query ($sql_create_table_blog, $conn);
; Quot;;
$config_strings.=.quot; \$user=\.quot;.Quot;.$user..Quot; \.quot; \n.quot;
$config_strings.=.quot; \$psw=\.quot. Sql_connect (\$host, \$user, \$psw); \n.quot;
$config_strings.=.quot; mysql_select_db (\$db, \$conn); \n.quot;
>; = fopen ($lockfile,'w');
fwrite ($fp2,'1212');
Fclose ($fp2);
> Fiction: for some large source code, the most core principles are also these, not necessary for beginners. To understand the complex PHP installation program, first to master the simple installation files of PHP source code, the complex is not difficult, through the operation of the above program, the PHP configuration file will automatically generate config.php, this is a file with the MySQL database, and will also generate a install.lock file, this is To determine whether files have been successfully installed, you will also create a new MySQL database that you manually add to the MySQL database.