Chapter One Introduction to PHP
PHP is a server-built script language that makes it a reality to quickly develop dynamic web on UNIX.
PHP was conceived by Rasmus Lerdorf in the fall of 1994. The earliest unpublished version was on his homepage to keep in touch with the people who watched his online resume. The first user-delivered version was released at the beginning of 1995, and it was only used as a personal homepage making tool. It consisted only of a very simple analysis engine with few macro instructions and a set of tools for home page feedback (a guest book, a counter, and something else). In 1995, Rasmus rewritten the entire parser and named Php/fi 2. Fi comes from another package of HTML form integration data that he wrote. He incorporated the Personal homepage tools, form integration tools, and added support for the mSQL database, so there was php/fi. The php/fi then spread at an astonishing speed, and people began to use it extensively to write programs.
We can't exactly count its use, but according to estimates by the end of 1996, there are at least 15,000 sites in the world using Php/fil. This number has grown to more than 50,000 sites by the year 1997. We also found a major twist in the development of PHP during the 1997. This is the development of PHP from a Rasmus personal hobby to a group of programmers who have organized jobs. Later, this parser was Zeev Suraski and Andi Gutmans rewrite, through this comprehensive rewrite, a large number of PHP/FI function was ported to PHP, and became the basic prototype of PHP.
By the middle of 1998, there had been a large number of commercially available products, such as C2 's stronghold Web server and Redhat Linux bundled php/fi parsers or PHP parsers, based on Netcraft estimates of conservative data, PHP has been the world's 150, 000 sites are used. Through further analysis, we know that the number of uses is much greater than that of the enterprise-class Web server, which uses the Netscape flagship product. PHP employs the syntax of C, Java, and Perl in large numbers, and adds a variety of PHP features. One of the differences between languages like JavaScript is that PHP executes on the server, and the client sees the result of its running on the server, which means that you have to have WEB SERVER support if you want to use PHP scrpit.
PHP supports HTTP authentication, cookies, and GIF image creation, and one of its most representative features is its database layer, which makes it easy to write database based pages. The following are the databases currently supported:
Oracle, Sybase, mSQL, MySQL, Informix, Solid dBase, ODBC, Unix dbm, PostgreSQL, Adabas D,filepro.
PHP also supports network programming with services using POP3, HTTP, SNMP, NNTP, IMAP, and so on.
PHP's Program mode
There are three ways to go from HTML to "PHP program mode":
The first method: <?php PHP statement;?>
Such as:
<?php Echo ("This is the simplest, a SGML processing Instructionn");?>
The second method: <?php PHP statement;?>
Such as:
<?php echo ("If you want to serve XML documents, does like Thisn");?>
The third method:
<script language= "PHP" >
PHP statements;
</script>
Such as:
<script language= "PHP" >
Echo ("Some editors" (like FrontPage) don t like processing instructions);
</script>
Chapter II Variables
PHP supports the following types of variables:
(i), internal variables
There are mainly integers (interger), floating-point numbers (Float-point numbers), strings (string), arrays (array), objects (object).
1 Initialization variables
To initialize a variable in PHP, you simply assign it a value. For most types, this is the most straightforward. For arrays and objects, you can use other methods.
2 Initializing an array
Arrays can be assigned using one of two methods: Using a series of consecutive values, or using the array () function to construct (see the array Functions section).
To add a continuous number to an array, you simply assign the value to an array variable without the subscript. The value is added to the array as the last element of the array.
Cases:
$names [] = "Jill"; $names [0] = "Jill"
$names [] = "Jack"; $names [1] = "Jack"
Similar to C and Perl, array subscripts start at 0.
3 Initializing objects
To initialize an object, you need to establish a variable of that type with the new statement.
class Foo {
function Do_foo () {
echo "doing foo.";
}
}
$bar = new Foo;
$bar->do_foo ();
4 variable Scopes