Internet Technologies 简明教程
PHP
Introduction
PHP 是 Hypertext Preprocessor (PHP) 的首字母缩写,是一种编程语言,允许Web开发人员创建与数据库交互的动态内容。PHP主要用于开发基于Web的软件应用程序。
PHP is acronym of Hypertext Preprocessor (PHP) is a programming language that allows web developers to create dynamic content that interacts with databases.PHP is basically used for developing web based software applications.
PHP最初是一个小型开源项目,随着越来越多的人发现它的用处,它逐渐发展起来。拉斯姆斯·勒多夫在1994年发布了第一个版本的PHP。
PHP started out as a small open source project that evolved as more and more people found out how useful it was. Rasmus Lerdorf unleashed the first version of PHP way back in 1994.
Key Points
Key Points
-
PHP is a recursive acronym for "PHP: Hypertext Preprocessor".
-
PHP is a server side scripting language that is embedded in HTML. It is used to manage dynamic content, databases, session tracking, even build entire e-commerce sites.
-
It is integrated with a number of popular databases, including MySQL, PostgreSQL, Oracle, Sybase, Informix, and Microsoft SQL Server.
-
PHP is pleasingly zippy in its execution, especially when compiled as an Apache module on the Unix side. The MySQL server, once started, executes even very complex queries with huge result sets in record-setting time.
-
PHP supports a large number of major protocols such as POP3, IMAP, and LDAP. PHP4 added support for Java and distributed object architectures (COM and CORBA), making n-tier development a possibility for the first time.
Uses of PHP
PHP 现在已成为 Web 开发人员中流行的脚本语言,原因如下 −
PHP has now become a popular scripting language among web developer due to the following reasons −
-
PHP performs system functions, i.e. from files on a system it can create, open, read, write, and close them.
-
PHP can handle forms, i.e. gather data from files, save data to a file, through email you can send data, return data to the user.
-
You add, delete, modify elements within your database through PHP.
-
Access cookies variables and set cookies.
-
Using PHP, you can restrict users to access some pages of your website.
-
It can encrypt data.
Characteristics
五个重要的特性使得 PHP 的实用性成为可能 −
Five important characteristics make PHP’s practical nature possible −
-
Simplicity
-
Efficiency
-
Security
-
Flexibility
-
Familiarity
"Hello World" Script in PHP
要了解 PHP,首先从简单的 PHP 脚本开始。由于“Hello, World!”是一个基本的示例,因此我们将首先创建一个友好的“Hello, World!”脚本。
To get a feel for PHP, first start with simple PHP scripts. Since "Hello, World!" is an essential example, first we will create a friendly little "Hello, World!" script.
正如前面提到的,PHP 嵌入在 HTML 中。这意味着在正常的 HTML 中(或在您使用最新技术时使用 XHTML 中),您将拥有像这样的 PHP 语句 −
As mentioned earlier, PHP is embedded in HTML. That means that in amongst your normal HTML (or XHTML if you’re cutting-edge) you’ll have PHP statements like this −
<html>
<head>
<title>Hello World</title>
</head>
<body>
<?php echo "Hello, World!";?>
</body>
</html>
它将产生以下结果 −
It will produce following result −
Hello, World!
如果您检查上述示例的 HTML 输出,您会注意到该 PHP 代码不存在于从服务器发送到您的 Web 浏览器的文件中。该 Web 页面中存在的全部 PHP 均已被处理并从该页面中删除;从 Web 服务器返回到客户端的唯一内容是纯 HTML 输出。
If you examine the HTML output of the above example, you’ll notice that the PHP code is not present in the file sent from the server to your Web browser. All of the PHP present in the Web page is processed and stripped from the page; the only thing returned to the client from the Web server is pure HTML output.
所有 PHP 代码都必须包含在 PHP 解析器识别的三个特殊标记之一中。
All PHP code must be included inside one of the three special markup tags ate are recognised by the PHP Parser.
<?php PHP code goes here ?>
<? PHP code goes here ?>
<script language="php"> PHP code goes here </script>