Php 简明教程

PHP Tutorial

What is PHP?

PHP 是一种开源通用脚本语言,广泛用于网站开发。它由 Rasmus Lerdorf 开发。PHP 代表递归首字母缩写词 PHP: 超文本预处理器。

PHP is an open-source general purpose scripting language, widely used for website development. It is developed by Rasmus Lerdorf. PHP stands for a recursive acronym PHP: Hypertext Preprocessor.

PHP 是世界上最流行的服务器端编程语言。其最新版本为 PHP 8.2.8,于 2023 年 7 月 4 日发布。

PHP is the world’s most popular server-side programming language. Its latest version PHP 8.2.8, released on July 4th, 2023.

PHP 是一种嵌入在 HTML 中的服务器端脚本语言。PHP 是一种跨平台语言,能够在所有主要的操作系统平台上运行,并且与大多数 Web 服务器程序(例如 Apache、IIS、lighttpd 和 nginx)兼容。

PHP is a server-side scripting language that is embedded in HTML. PHP is a cross-platform language, capable of running on all major operating system platforms and with most of the web server programs such as Apache, IIS, lighttpd and nginx.

PEAR 和 Composer 中提供了大量的可重用类和库。PEAR(PHP 扩展和应用程序存储库)是一个可重用 PHP 库或类的分发系统。Composer 是 PHP 中的依赖管理工具。

A large number of reusable classes and libraries are available on PEAR and Composer. PEAR (PHP Extension and Application Repository) is a distribution system for reusable PHP libraries or classes. Composer is a dependency management tool in PHP.

Why Learn PHP?

PHP 是创建互动网站和 Web 应用程序的首选语言之一。PHP 脚本可以轻松嵌入到 HTML 中。借助 PHP,你可以构建:

PHP one of the most preferred languages for creating interactive websites and web applications. PHP scripts can be easily embedded into HTML. With PHP, you can build

  1. Web Pages and Web-Based Applications

  2. Content Management Systems, and

  3. Ecommerce Applications etc.

为了加快 Web 应用程序开发速度,已经开发了许多基于 PHP 的 Web 框架。例如 WordPress、Laravel、Symfony 等。

A number of PHP based web frameworks have been developed to speed-up the web application development. The examples are WordPress, Laravel, Symfony etc.

Advantages of Using PHP

对于学生和在职人员来说,PHP 是成为优秀软件工程师的必备条件,尤其是在他们从事 Web 开发领域时。

PHP is a MUST for students and working professionals to become great Software Engineers, especially when they are working in Web Development Domain.

下面列出了一些使用 PHP 最显着的优点:

Some of the most notable advantages of using PHP are listed below −

  1. PHP is a multi-paradigm language that supports imperative, functional, object-oriented, and procedural programming methodologies.

  2. 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.

  3. PHP is integrated with a number of popular databases including MySQL, PostgreSQL, Oracle, Sybase, Informix, and Microsoft SQL Server.

  4. 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.

  5. PHP supports a number of protocols such as POP3, IMAP, and LDAP. PHP supports distributed object architectures (COM and CORBA), which makes n-tier development possible.

  6. PHP is forgiving: PHP language tries to be as forgiving as possible.

  7. PHP has a familiar C-like syntax.

PHP 有五个重要的特征,使其具有可行性:简单性、高效性、安全性、灵活性及熟悉性。

There are five important characteristics of PHP that make its practical nature possible: Simplicity, Efficiency, Security, Flexibility, and Familiarity.

Hello World Using PHP

为了让大家稍微熟悉 PHP,我将提供一个小型传统 PHP HelloWorld 程序。您可以使用演示链接尝试它。

Just to give you a little excitement about PHP, I’m going to give you a small conventional PHP Hello World program. You can try it using the Demo link.

<?php
   echo "Hello, World!";
?>

Audience

本 PHP 教程专为对 PHP 概念完全不了解但对计算机编程有基本了解的程序员而设计。

This PHP tutorial is designed for programmers who are completely unaware of PHP concepts but have a basic understanding on computer programming.

Prerequisites

在继续学习本教程之前,您需要做的就是对计算机编程有一个基本了解。了解 HTML、CSS、JavaScript 和数据库将是一个额外的优势。

Before proceeding with this tutorial, all that you need to have is a basic understanding of computer programming. Knowledge of HTML, CSS, JavaScript, and databases will be an added advantage.

Frequently Asked Questions about PHP

关于 PHP,有一些非常常见的常见问题 (FAQ),本节将尝试简要解答这些问题。

There are some very Frequently Asked Questions(FAQ) about PHP, this section tries to answer them briefly.