Install PHP 5 on Windows
时间:2006-03-07 来源:liuxingyuyuni
Step 1: Download Apache
官方URL:
http://httpd.apache.org/download.cgi
Step 2: 确保80端口未被占用[停掉IIS]
Before we install Apache, we need to make sure the Windows Internet Information Server (IIS) is disabled (if it is installed and running). The reason is that IIS and Apache are both web servers and they will conflict if they are both running at the same time. Note that if you want continue to use IIS (e.g. for local ASP.NET website development), you will be able to easily switch IIS and Apache on and off so you can use both. This step just tells you how to switch IIS off temporarily so we can install Apache.
Step 3: Install Apache
We will now execute the file we which we previously downloaded. This is a standard Windows installation file and thus very straightforward.
Step 4: Download PHP5
官方URL:
http://www.php.net/downloads.php
Step 5: Install PHP5
(1). We will now install PHP5 by unpacking and installing the files in the zip file you just downloaded
(2). You now want to MOVE all the unzipped PHP5 files and directories to c:\php. So in Windows Explorer, go to C:\download\php5\php-5.0.2-Win32\ and press CTRL-A to select all the files, then press CTRL-X to copy them. Now create a directory called c:\php and copy all the files into that directory by going to it and pressing CTRL-V. If you have completed this step correctly, you will see in the c:\php directory four folders and over 20 files.
(3). Now move (don't just copy) the file c:\php\php5ts.dll to c:\windows\php5ts.dll (or if you don't have a c:\windows directory, move it to c:\winnt).
(4). PHP5 is now installed on your computer, but you still need to configure it to work with Apache, which we will do in the next step.
Step 6: Configure PHP5 to Work with Apache
We now need to tell the Apache web server what to do when it encounters a .php5 file. Some changes will be made to the Apache configuration file and some will be made to the PHP configuration file.
(1) . With the Windows Explorer, create the folder c:\webs\test. This will be our test website.
(2). Rename the c:\php\php.ini-dist to c:\php\php.ini, then make the following changes in the c:\php\php.ini file: (1) doc_root = "c:\webs\test" and (2) extension_dir = "C:\php\ext". Note that you should use BACKSLASHES in the php.ini file.
(3). In the file C:\Program Files\Apache Group\Apache2\conf\httpd.conf, change the DocumentRoot entry to: DocumentRoot "C:/webs/test". Note that you should use FORWARD SLASHES in the http.conf file.
(4). Also in the file C:\Program Files\Apache Group\Apache2\conf\httpd.conf, change the Directory entry to: .Note that you should use FORWARD SLASHES in the http.conf file.
(5). Again in the C:\Program Files\Apache Group\Apache2\conf\httpd.conf file, add the following lines: hint: to find this position fast, search for "media types"
ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php-cgi.exe"
SetEnv PHPRC c:/php
(6). Lastly, we need to make one last change to this C:\Program Files\Apache Group\Apache2\conf\httpd.conf file. Find the "DirectoryIndex" entry and add "index.php" to the end of the line as shown in this screenshot.
(7). In order for the changes to take effect, you need to restart Apache. To do this, click the Apache symbol in the lower right-hand corner of your task bar. In the little menu that pops up there, click Apache 2 and then Restart.
(8). After about 10 seconds, Apache will have restarted, PHP5 will be configured. Go on to the next step to test your configuration.
Step 7: Test PHP5
You have now installed Apache and PHP5 and have configured PHP5. We will now test your configuration of PHP5 to make sure Apache can correctly serve PHP5 files.
(1). Create the file c:\webs\test\index.php5 with the following line:
Today is
(2). With your browser, go to http://localhost. If you see the current date on your screen as in this screenshot, then PHP5 has been successfully installed and configured with Apache.
Step 8: Test SQLite
SQLite is a file-based database that is bundled with PHP5. If you followed the instructions in this workshop then SQLite should already be installed. To test if it is, we will create a little file to create, write, read, and display data from an SQLite database.
Do This:
(1). Create this file: c:\webs\test\testSqlite.php5 and copy in the following code
//create table
if(file_exists("test.db")) {
$weNeedToCreateTheDatabase = false;
} else {
$weNeedToCreateTheDatabase = true;
}
//create or open database
$db = sqlite_open("test.db") or die("failed to open/create the database");
//create table
if($weNeedToCreateTheDatabase) {
sqlite_query($db, "CREATE TABLE Members(FirstName,LastName)");
}
//add info
sqlite_query($db,"INSERT INTO Members VALUES ('Jim', 'Rockerton')");
//get info
$dt = sqlite_query($db, "SELECT * FROM Members");
while ($row = sqlite_fetch_array($dt)) {
echo "row: $row[FirstName] $row[LastName]";
}
//close database
sqlite_close($db);
?>
(2). Run the page in your browser by going to http://localhost/testSqlite.php5 and you should see the following:
(3). Each time you press the Reload button on your browser, a new record will be added to the database and a new line should appear. If your screen resembles the following, then Sqlite is properly installed:
Step 9: Download SQLiteManager
In this step we are going to download a free tool which will allow you to login and edit the data on your website online via your browser.
Do This:
(1). In your browser, go to
http://sourceforge.net/projects/sqlitemanager
(2). In the box labeled Latest File Releases in the row labeled sqlitemanager, click on the link labeled Download
(3). In the box labeled sqlitemanager click on the link labeled SQLiteManager-1.0.3.zip:
(4). Click on the download icon in the first row:
(5). Save the download file as C:\downloads\sqlitemanager\SQLiteManager-1.0.3.zip:
(6). In your Windows Explorer, check the folder C:\downloads\sqlitemanager. If it contanis a file called SQLiteManager-1.0.3.zip, then you have successfully downloaded SQLiteManager.
Step 10: Set up SQLiteManager
In this step we will set up the SQLiteManager tool which you downloaded in the preceding step
Do This:
(1). In Windows Explorer, go to C:\downloads\sqlitemanager and unzip the file labeled SQLiteManager-1.0.3.zip into a directory of the same name:
(2). Go to the directory C:\downloads\sqlitemanager\SQLiteManager-1.0.3\SQLiteManager-1.0.3 and select all the files in that directory by pressing CTRL-A and then CUT all the files by pressing CTRL-X:
(3). Create a new directory called C:\webs\test\sqlitemanager and then PASTE the files into this direcctory by pressing CTRL-V:
(4). In your browser, go to http://localhost/sqliteManager and you should see the following
(5). You want to delete the test database that they provide. So click on the database name Test on the left-hand side, and then click on Delete button on the right-hand side. Then confirm the deletion by clicking on the OK button that pops up.
(6). Now we want to set up the SQLiteManager tool to recognize the test database which we created in a previous step. In the textbox labeled Name, type Test Database. In the textbox above the Save button, type in ../test.db, which means you want to go back one directory and use the C:\webs\test\test.db file that we created.
(7). You will see your database appear and in the middle of the screen you will see your Members table listed. Click on the hour glass icon in that line:
(8). The records which you added by clicking reload in the previous step will be shown. Click on the Insert button to add another record
(9). Type in Angie and Smith in the far-right text boxes, then click on the Save button.
(10). You now see that Angie Smith was added to the table.
(11). Now when you go to http://localhost/testSqlite.php again in your browser to view your SQLite test, you see that the name we added via the SQLiteManager tool now appears on the page:
Step 11: Password protect SQLiteManager
In this step we will password protect the SQLiteManager page so that you can upload it to your web site and edit the content of your website online via your browser.
....................... :( 没有介绍.............
Step 12: Download MySQL 4.1
Read This:
Although PHP 5 now comes with simple, easy and powerful SQLite database, here are two reasons why you would want to use MySQL instead:
(1). 下载 官方URL:
http://dev.mysql.com/downloads
.
Step 13: Install MySQL 4.1
We will now use the file you just downloaded to install MySQL 4.1 on your computer.
(1). In your Windows Explorer, go to c:\downloads\mysql4 and double-click on the icon named mysql-4.1.7-essential-win.msi.
(2). After about 15 seconds you will see the first screen of the MySQL Server 4.1 - Setup Wizard. Click the Next button.
(3). Choose Typical and click the Next button.
(4). Click the Install button
(5). Wait for it to install which can take up to 30 seconds.
(6). Check the Skip Sign-Up choice and click Next.
(7). Make sure the Configure the MySQL Server now checkbox is checked and click the Finish button
(8). The first screen of the MySQL Server Instance Configuration Wizard will appear. Click the Next button
(9). Choose Detailed Configuration and click the Next button.
(10). Choose Developer Machine and click the Next button
(11). Choose Multifunctional Database and click the Next button
(12). Make sure Installation Path is chosen and click the Next button.
(13). Make sure Decision Support (DSS)/OLAP is chosen and click the Next button
(14). Make sure Enable TCP/IP Networking is chosen and leave the Port Number at 3306, then click the Next button.
(15). Choose Best Support For Multilingualism and click the Next button
(16). Make sure Install As Windows Service is clicked, then choose MySQL41 as the name, and click the Next button.
(17). Make sure Modify Security Settings is checked. Enter admin and admin for the password. Make sure you check Root may only connect from localhost. Then click the Next button.
(18). Click the Execute button.
Step 14: Create a Database Table using MySQL 4.1 Client
In this step we will use the MySQL 4.1 client software to create a database table (so that we can dislay its data on a web page in the next step). In order to do this, we are going to have to enter commands in at the command prompt on your Windows machine.
(1). In order to get to the command prompt, click the Windows Start button and choose Run. Then type in cmd and click the OK button.
(2). At the command prompt, type cd "C:\Program Files\MySQL\MySQL Server 4.1\bin" and hit the Enter key
(3). Then type mysql -u root -p and when asked for the password, type admin. You will then see the MySQL client prompt.
(4). Type in the following lines in order to create the database named demo and a table within that database named members:
mysql>use somedb;
database changed
mysql>create table members (firstname varchar(50), lastname varchar(50), lastname varchar(50));
Query OK, 0rows affected (0.12 sec)
mysql>
(5). Now type in the following lines which will create two records in the members table of the demo database:
select insert update delete
(6). Now exit the MySQL client by typing quit;.
Step 15: Set up PHP to work with MySQL 4.1
We now need to make a few changes to PHP so that it knows what to do when it encouters a MySQL command
First of all, check the c:\php directory and make sure that the files libmysqli.dll and php_mysqli.dll are both there. If they are not there, check the c:\php\ext directory and copy the files into c:\php
Then open up the file c:\php\php.ini in your editor and ADD the line extension=php_mysqli.dll.
In order for the changes to take effect, you need to restart Apache. To do this, click the Apache symbol in the lower right-hand corner of your task bar. In the little menu that pops up there, click Apache 2 and then Restart.
After about 10 seconds, your PHP will be ready to accept mysqli commands to talk to the MySQL 4.1 database
Step 16: Test PHP5/MySQL in browser
We will now create a PHP 5 page which connects to your MySQL database called demo, reads the names out of the table members and displays them in the browser.
Create a file c:\webs\test\testmysql41.php and paste in the following code
$mysqli = new mysqli('localhost','root','admin');
$mysqli->select_db('demo');
$result = $mysqli->query("SELECT * FROM members");
while($row = $result->fetch_assoc()) {
print $row['firstName'] . ' ' . $row['lastName'] . '';
}
$result->close();
?>
In your browser, go to http://localhost/testmysql41.php. If you see the following two names appear in your browser, this means that your MySQL 4.1 database works with your PHP 5 installation.
Step 17: Add XSLT
One difficulty with PHP4 was the lack of XSLT support. With PHP5, you simply have to include a module and you have access to powerful functions which parse XML and XSLT. This step shows you how simple it is to add this XSLT support
(1). In the file C:\php\php.ini, remove the leading semicolon from the line which reads ;extension=php_xsl.dll
(2). In order for the changes to take effect, you need to restart Apache. To do this, click the Apache symbol in the lower right-hand corner of your task bar. In the little menu that pops up there, click Apache 2 and then Restart
Step 18: Test XSLT
(1). Create the following XML file called c:\webs\test\test.xml:
Jim
Rockerberry
34
Sally
M脙录ller
12
Hank
Jamestown
44
(2). Create the following XSL file called c:\webs\test\test.xsl:
Test of XML/XSLT parsing:
, score =
(3). Now create the following PHP file called c:\webs\test\testXslt.php5
load('test.xml');
$xsl = new DomDocument;
$xsl->load('test.xsl');
$xslt = new Xsltprocessor;
$xslt->importStylesheet($xsl);
$transformation = $xslt->transformToXml($xml);
echo $transformation;
?>
(4). Now look at the file http://localhost/testXslt.php5 in your browser. If XSLT is installed properly then you should see the following. Note that the German characters appear correctly which means that the XSLT functions handle ISO-8859-1 character coding correctly, something that SimpleXML (unfortunately) doesn't do yet.
go on .....
http://www.tanguay.at/installPhp5.php5?step=21
官方URL:
http://httpd.apache.org/download.cgi
Step 2: 确保80端口未被占用[停掉IIS]
Before we install Apache, we need to make sure the Windows Internet Information Server (IIS) is disabled (if it is installed and running). The reason is that IIS and Apache are both web servers and they will conflict if they are both running at the same time. Note that if you want continue to use IIS (e.g. for local ASP.NET website development), you will be able to easily switch IIS and Apache on and off so you can use both. This step just tells you how to switch IIS off temporarily so we can install Apache.
Step 3: Install Apache
We will now execute the file we which we previously downloaded. This is a standard Windows installation file and thus very straightforward.
Step 4: Download PHP5
官方URL:
http://www.php.net/downloads.php
Step 5: Install PHP5
(1). We will now install PHP5 by unpacking and installing the files in the zip file you just downloaded
(2). You now want to MOVE all the unzipped PHP5 files and directories to c:\php. So in Windows Explorer, go to C:\download\php5\php-5.0.2-Win32\ and press CTRL-A to select all the files, then press CTRL-X to copy them. Now create a directory called c:\php and copy all the files into that directory by going to it and pressing CTRL-V. If you have completed this step correctly, you will see in the c:\php directory four folders and over 20 files.
(3). Now move (don't just copy) the file c:\php\php5ts.dll to c:\windows\php5ts.dll (or if you don't have a c:\windows directory, move it to c:\winnt).
(4). PHP5 is now installed on your computer, but you still need to configure it to work with Apache, which we will do in the next step.
Step 6: Configure PHP5 to Work with Apache
We now need to tell the Apache web server what to do when it encounters a .php5 file. Some changes will be made to the Apache configuration file and some will be made to the PHP configuration file.
(1) . With the Windows Explorer, create the folder c:\webs\test. This will be our test website.
(2). Rename the c:\php\php.ini-dist to c:\php\php.ini, then make the following changes in the c:\php\php.ini file: (1) doc_root = "c:\webs\test" and (2) extension_dir = "C:\php\ext". Note that you should use BACKSLASHES in the php.ini file.
(3). In the file C:\Program Files\Apache Group\Apache2\conf\httpd.conf, change the DocumentRoot entry to: DocumentRoot "C:/webs/test". Note that you should use FORWARD SLASHES in the http.conf file.
(4). Also in the file C:\Program Files\Apache Group\Apache2\conf\httpd.conf, change the Directory entry to: .Note that you should use FORWARD SLASHES in the http.conf file.
(5). Again in the C:\Program Files\Apache Group\Apache2\conf\httpd.conf file, add the following lines: hint: to find this position fast, search for "media types"
ScriptAlias /php/ "c:/php/"
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php-cgi.exe"
SetEnv PHPRC c:/php
(6). Lastly, we need to make one last change to this C:\Program Files\Apache Group\Apache2\conf\httpd.conf file. Find the "DirectoryIndex" entry and add "index.php" to the end of the line as shown in this screenshot.
(7). In order for the changes to take effect, you need to restart Apache. To do this, click the Apache symbol in the lower right-hand corner of your task bar. In the little menu that pops up there, click Apache 2 and then Restart.
(8). After about 10 seconds, Apache will have restarted, PHP5 will be configured. Go on to the next step to test your configuration.
Step 7: Test PHP5
You have now installed Apache and PHP5 and have configured PHP5. We will now test your configuration of PHP5 to make sure Apache can correctly serve PHP5 files.
(1). Create the file c:\webs\test\index.php5 with the following line:
Today is
(2). With your browser, go to http://localhost. If you see the current date on your screen as in this screenshot, then PHP5 has been successfully installed and configured with Apache.
Step 8: Test SQLite
SQLite is a file-based database that is bundled with PHP5. If you followed the instructions in this workshop then SQLite should already be installed. To test if it is, we will create a little file to create, write, read, and display data from an SQLite database.
Do This:
(1). Create this file: c:\webs\test\testSqlite.php5 and copy in the following code
//create table
if(file_exists("test.db")) {
$weNeedToCreateTheDatabase = false;
} else {
$weNeedToCreateTheDatabase = true;
}
//create or open database
$db = sqlite_open("test.db") or die("failed to open/create the database");
//create table
if($weNeedToCreateTheDatabase) {
sqlite_query($db, "CREATE TABLE Members(FirstName,LastName)");
}
//add info
sqlite_query($db,"INSERT INTO Members VALUES ('Jim', 'Rockerton')");
//get info
$dt = sqlite_query($db, "SELECT * FROM Members");
while ($row = sqlite_fetch_array($dt)) {
echo "row: $row[FirstName] $row[LastName]";
}
//close database
sqlite_close($db);
?>
(2). Run the page in your browser by going to http://localhost/testSqlite.php5 and you should see the following:
(3). Each time you press the Reload button on your browser, a new record will be added to the database and a new line should appear. If your screen resembles the following, then Sqlite is properly installed:
Step 9: Download SQLiteManager
In this step we are going to download a free tool which will allow you to login and edit the data on your website online via your browser.
Do This:
(1). In your browser, go to
http://sourceforge.net/projects/sqlitemanager
(2). In the box labeled Latest File Releases in the row labeled sqlitemanager, click on the link labeled Download
(3). In the box labeled sqlitemanager click on the link labeled SQLiteManager-1.0.3.zip:
(4). Click on the download icon in the first row:
(5). Save the download file as C:\downloads\sqlitemanager\SQLiteManager-1.0.3.zip:
(6). In your Windows Explorer, check the folder C:\downloads\sqlitemanager. If it contanis a file called SQLiteManager-1.0.3.zip, then you have successfully downloaded SQLiteManager.
Step 10: Set up SQLiteManager
In this step we will set up the SQLiteManager tool which you downloaded in the preceding step
Do This:
(1). In Windows Explorer, go to C:\downloads\sqlitemanager and unzip the file labeled SQLiteManager-1.0.3.zip into a directory of the same name:
(2). Go to the directory C:\downloads\sqlitemanager\SQLiteManager-1.0.3\SQLiteManager-1.0.3 and select all the files in that directory by pressing CTRL-A and then CUT all the files by pressing CTRL-X:
(3). Create a new directory called C:\webs\test\sqlitemanager and then PASTE the files into this direcctory by pressing CTRL-V:
(4). In your browser, go to http://localhost/sqliteManager and you should see the following
(5). You want to delete the test database that they provide. So click on the database name Test on the left-hand side, and then click on Delete button on the right-hand side. Then confirm the deletion by clicking on the OK button that pops up.
(6). Now we want to set up the SQLiteManager tool to recognize the test database which we created in a previous step. In the textbox labeled Name, type Test Database. In the textbox above the Save button, type in ../test.db, which means you want to go back one directory and use the C:\webs\test\test.db file that we created.
(7). You will see your database appear and in the middle of the screen you will see your Members table listed. Click on the hour glass icon in that line:
(8). The records which you added by clicking reload in the previous step will be shown. Click on the Insert button to add another record
(9). Type in Angie and Smith in the far-right text boxes, then click on the Save button.
(10). You now see that Angie Smith was added to the table.
(11). Now when you go to http://localhost/testSqlite.php again in your browser to view your SQLite test, you see that the name we added via the SQLiteManager tool now appears on the page:
Step 11: Password protect SQLiteManager
In this step we will password protect the SQLiteManager page so that you can upload it to your web site and edit the content of your website online via your browser.
....................... :( 没有介绍.............
Step 12: Download MySQL 4.1
Read This:
Although PHP 5 now comes with simple, easy and powerful SQLite database, here are two reasons why you would want to use MySQL instead:
- Websites which frequently write to the database: If you are doing frequent CHANGES to your database with INSERT INTO or UPDATE, e.g. if you have a site where 100 people are constantly blogging, posting messages, extensive logging, etc., then using SQLite will make your site slow. Why? Because an SQLite database exists as a single file and when you CHANGE that file, SQLite locks the whole database, so that if someone is trying to insert data at the same time into another table, they will have to wait. "Real" databases such as MySQL and Postgresql allow simultaneous write access to the database.
- Websites which need high security: If security is an issue to you (e.g. if you store logins and passwords in your database), then you probably want to use MySQL instead of SQLite. With MySQL you can set up various users who have various access to various parts of the database. With SQLite everybody has access to everything. If a user can access the .db file which contains your SQLite database then he has access to all your data. People who use SQLite on a web site should not forget that if their SQLite .db file is simply stored in a sub-directory somewhere on the website, then a user can download your whole database and then look through it to find login and passwords, etc. When you use MySQL, your database is by default safely tucked away where users have to have special access logins and passwords to get to it.
(1). 下载 官方URL:
http://dev.mysql.com/downloads
.
Step 13: Install MySQL 4.1
We will now use the file you just downloaded to install MySQL 4.1 on your computer.
(1). In your Windows Explorer, go to c:\downloads\mysql4 and double-click on the icon named mysql-4.1.7-essential-win.msi.
(2). After about 15 seconds you will see the first screen of the MySQL Server 4.1 - Setup Wizard. Click the Next button.
(3). Choose Typical and click the Next button.
(4). Click the Install button
(5). Wait for it to install which can take up to 30 seconds.
(6). Check the Skip Sign-Up choice and click Next.
(7). Make sure the Configure the MySQL Server now checkbox is checked and click the Finish button
(8). The first screen of the MySQL Server Instance Configuration Wizard will appear. Click the Next button
(9). Choose Detailed Configuration and click the Next button.
(10). Choose Developer Machine and click the Next button
(11). Choose Multifunctional Database and click the Next button
(12). Make sure Installation Path is chosen and click the Next button.
(13). Make sure Decision Support (DSS)/OLAP is chosen and click the Next button
(14). Make sure Enable TCP/IP Networking is chosen and leave the Port Number at 3306, then click the Next button.
(15). Choose Best Support For Multilingualism and click the Next button
(16). Make sure Install As Windows Service is clicked, then choose MySQL41 as the name, and click the Next button.
(17). Make sure Modify Security Settings is checked. Enter admin and admin for the password. Make sure you check Root may only connect from localhost. Then click the Next button.
(18). Click the Execute button.
Step 14: Create a Database Table using MySQL 4.1 Client
In this step we will use the MySQL 4.1 client software to create a database table (so that we can dislay its data on a web page in the next step). In order to do this, we are going to have to enter commands in at the command prompt on your Windows machine.
(1). In order to get to the command prompt, click the Windows Start button and choose Run. Then type in cmd and click the OK button.
(2). At the command prompt, type cd "C:\Program Files\MySQL\MySQL Server 4.1\bin" and hit the Enter key
(3). Then type mysql -u root -p and when asked for the password, type admin. You will then see the MySQL client prompt.
(4). Type in the following lines in order to create the database named demo and a table within that database named members:
mysql>use somedb;
database changed
mysql>create table members (firstname varchar(50), lastname varchar(50), lastname varchar(50));
Query OK, 0rows affected (0.12 sec)
mysql>
(5). Now type in the following lines which will create two records in the members table of the demo database:
select insert update delete
(6). Now exit the MySQL client by typing quit;.
Step 15: Set up PHP to work with MySQL 4.1
We now need to make a few changes to PHP so that it knows what to do when it encouters a MySQL command
First of all, check the c:\php directory and make sure that the files libmysqli.dll and php_mysqli.dll are both there. If they are not there, check the c:\php\ext directory and copy the files into c:\php
Then open up the file c:\php\php.ini in your editor and ADD the line extension=php_mysqli.dll.
In order for the changes to take effect, you need to restart Apache. To do this, click the Apache symbol in the lower right-hand corner of your task bar. In the little menu that pops up there, click Apache 2 and then Restart.
After about 10 seconds, your PHP will be ready to accept mysqli commands to talk to the MySQL 4.1 database
Step 16: Test PHP5/MySQL in browser
We will now create a PHP 5 page which connects to your MySQL database called demo, reads the names out of the table members and displays them in the browser.
Create a file c:\webs\test\testmysql41.php and paste in the following code
$mysqli = new mysqli('localhost','root','admin');
$mysqli->select_db('demo');
$result = $mysqli->query("SELECT * FROM members");
while($row = $result->fetch_assoc()) {
print $row['firstName'] . ' ' . $row['lastName'] . '';
}
$result->close();
?>
In your browser, go to http://localhost/testmysql41.php. If you see the following two names appear in your browser, this means that your MySQL 4.1 database works with your PHP 5 installation.
Step 17: Add XSLT
One difficulty with PHP4 was the lack of XSLT support. With PHP5, you simply have to include a module and you have access to powerful functions which parse XML and XSLT. This step shows you how simple it is to add this XSLT support
(1). In the file C:\php\php.ini, remove the leading semicolon from the line which reads ;extension=php_xsl.dll
(2). In order for the changes to take effect, you need to restart Apache. To do this, click the Apache symbol in the lower right-hand corner of your task bar. In the little menu that pops up there, click Apache 2 and then Restart
Step 18: Test XSLT
(1). Create the following XML file called c:\webs\test\test.xml:
Jim
Rockerberry
34
Sally
M脙录ller
12
Hank
Jamestown
44
(2). Create the following XSL file called c:\webs\test\test.xsl:
Test of XML/XSLT parsing:
, score =
(3). Now create the following PHP file called c:\webs\test\testXslt.php5
load('test.xml');
$xsl = new DomDocument;
$xsl->load('test.xsl');
$xslt = new Xsltprocessor;
$xslt->importStylesheet($xsl);
$transformation = $xslt->transformToXml($xml);
echo $transformation;
?>
(4). Now look at the file http://localhost/testXslt.php5 in your browser. If XSLT is installed properly then you should see the following. Note that the German characters appear correctly which means that the XSLT functions handle ISO-8859-1 character coding correctly, something that SimpleXML (unfortunately) doesn't do yet.
go on .....
http://www.tanguay.at/installPhp5.php5?step=21
相关阅读 更多 +