📄 00000096.htm
字号:
overhead of starting and stopping the script for each request. <BR> Also, your CGI scripts don't have to run on the same machine as the Web <BR> server when you use FastCGI. You can run your CGI scripts on a different <BR> host to take the load off your Web server and thereby distribute the load <BR> across several machines. <BR> The advantages of using FastCGI are first and foremost speed, but also the <BR> fact that you can make use of it without having to throw away your <BR> existing CGI code. With some simple modifications to your CGI scripts you <BR> can migrate them into a FastCGI environment. For more information on <BR> FastCGI, point your browser to www.fastcgi.org. <BR> PHP:Easy DB Access <BR> <BR> When building Web applications, it would be convenient if you could make <BR> the Web server look-up data in a SQL server and insert the data into HTML <BR> documents or templates without having to create and maintain CGI scripts. <BR> To get around the performance bottlenecks of a CGI-style interface and the <BR> tedium of putting HTML code inside print statements, you could embed a <BR> parser in the server which allows you to put code into your HTML markup. <BR> This is exactly what PHP does. <BR> PHP can also interpret input fields from forms and make the values <BR> available as variables in the programming language. Also, the interpreter <BR> can be compiled into the Apache Web server as a module. Now you only need <BR> to create an HTML document with code embedded and point your browser at <BR> the page. The Web server will automatically run the embedded code on <BR> loading the HTML file. <BR> Here's how it works. Imagine you have an HTML file containing a form: <BR> <BR><FORM ACTION="shoy database that OpenLink (www.openlink.co.uk) supports through the <BR> OpenLink broker. This means that you can use the features OpenLink <BR> provides to get persistent connections to databases and a single interface <BR> to several databases of different kinds. It also means that there's an <BR> easy way to use databases that aren't supported on your Web server <BR> platform. For instance, there are no client libraries for Oracle available <BR> under Linux (yet). If you Web server runs Linux and your database server <BR> runs Oracle under Solaris, OpenLink provides a way to use the database <BR> server from the Linux machine. <BR> To make database access more efficient, PHP offers persistent connections <BR> to databases in order to eliminate the need for connecting to the database <BR> every time. PHP will stay logged into the database between requests and <BR> re-use connections where possible. For some databases this makes database <BR> access considerably faster. <BR> Note that the connections are specific to the Web server process. There is <BR> currently no mechanism to pool connections within the main process of <BR> Apache and have the Web server processes share connections when needed. <BR> This means that if you have a large number of processes with persistent <BR> connections to your database, you will have an equally large number of <BR> connections to the database. <BR> As mentioned above, using OpenLink to pool connections in a middle tier <BR> might be a good option if this is a problem. Usually it is not a problem. <BR> Extending PHP <BR> Adding native support for a database or some custom functions could be <BR> awkward to implement in the PHP language itself; fortunately PHP is rather <BR> easy to extend. Besides the API documentation that comes with the PHP <BR> source distribution, there are many built-in functions you can look at for <BR> reference. <BR> Perhaps the most common problems when programming in C are memory and file <BR> descriptor leaks. You allocate memory, but when you are done using it you <BR> forget to give it back to the system. PHP provides a set of wrapper <BR> functions for allocating memory. When using these wrapper functions PHP <BR> will keep track of the memory you allocate and will then be able to clean <BR> up after your code when the memory is not needed anymore. <BR> PHP also provides a framework to handle persistent resources like database <BR> connections etc. This can boost your performance considerably when using <BR> PHP to communicate with systems that have a considerable startup cost <BR> associated with initiating a connection. As we mentioned earlier, database <BR> accesses can often be made persistent. <BR> Built-in Goodies <BR> PHP has a lot of built-in goodies that will come in handy when you want to <BR> develop Web applications. Since the cookie mechanism is a popular way of <BR> having the browser preserve state information across HTTP requests, PHP <BR> provides functions to manipulate cookies. Once a cookie is set its value <BR> can be accessed like a normal variable. <BR> For instance if your PHP code contains the following code: <BR> <BR> setcookie("session_id", "1234"); <BR> A cookie will be sent back to the browser and the next time the user <BR> accesses the site the cookie will be available through a variable with the <BR> same name as the cookie: <BR> <BR> echo "The session id is $session_id\n"; <BR> For more details on what other parameters you can specify to the <BR> setcookie() you should check out the documentation for PHP (see <BR> "Availability"). Among the other neat features offered in PHP is <BR> on-the-fly image generation using the GD library and support for TrueType <BR> fonts in images using the FreeType library. PHP also provides an easy <BR> interface to do file uploads from browsers, arbitrary precision math, you <BR> can talk to LDAP, and IMAP servers, you can query SNMP agents and you can <BR> even open files on other Web or FTP servers simply by using an URL instead <BR> of a regular file name. <BR> Development Using PHP <BR> Developing Web applications with PHP 3.0 is very straightforward. Once you <BR> have installed PHP 3.0 and set up the configuration properly you are ready <BR> to go. Since trying to parse all HTML pages isn't too much of a <BR>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -