Table of Contents
php echo $string ?>" >Hello,php echo $string ?>
Home php教程 php手册 PHP程序设计 第一章 什么是PHP?

PHP程序设计 第一章 什么是PHP?

Jun 21, 2016 am 09:02 AM
gt html lt nbsp php

 

  
  PHP
是编程语言和应用程序服务器的结合。PHP和其它的编程语言类似,使用变量存储临时数值,使用操作符处理变量。PHP的真正价值在于它是一个应用程序服务器。
  
  
当谈到应用程序服务器的时候,我是指一个把几个不同的技术组合为一个完整的套件的程序。这些技术包括:
  *
一个强壮的编程语言。
  *
存取数据库中存储的数据。
  *
支持 Internet协议,尤其是电子邮件和HTTP协议。
  
  
注意:应用程序服务器有许多其它的特性,这里只列出了最基本的特性。
  
  
由于提供了这些多种不同技术的前端接口,PHP可以使工作变的很容易。
  
本章的其它部分讲述了有关PHP的许多繁杂资料,以及它在应用软件开发中起到的作用。
  
  1.1
起源
  PHP
是由Rasums Lerdorf创建的,它开始是一个简单的用Perl语言编写的程序,用来记录Rasums Lerdorf自己在线简历的访问者。以后它又被用C语言重新写过,范围扩大到访问数据库。在这期间,有许多人向Rasums Lerdorf要此程序的拷贝,以便自己使用。Rasums Lerdorf为此写了一些介绍此程序的文档,并发布PHP v1.0。以后,越来越多的人开始使用PHP,并强烈要求增加一些其他的特性,如循环语句和数组变量等。到这时,其他的一些程序员也开始参与PHP源码的编写(主要有Zeev SurakiAndi Gutmans),很明显,此时的PHP为了以后的发展,必须重新编写。因此,PHP v3.0就出现了。
  1.2
特性
  PHP
的特性包括:
  *
开放源码 -- 所有的PHP源码都可以得到。事实上,所有的源码都包含在随书附带的光盘中。
  *
没有运行费用 -- PHP是免费的。
  *
基于服务器端 -- 由于PHP是在Web服务器端运行的,PHP程序可以很大、很复杂而不会降低客户端的运行速度。
  *
跨平台 -- 虽然本书是以Linux为重点介绍的,但PHP程序可以运行在UNIXLinux,或者Windows操作系统下。
  *
嵌入HTML -- 因为PHP语言可以嵌入到HTML内部,所以PHP很容易学习。
  *
简单的语言 -- JavaC++不同,PHP语言坚持以基本语言为基础,然而它的功能也强大到足以支持任何类型的Web站点。
  *
效率高 -- 和其它的解释性语言相比,PHP系统消耗较少的系统资源。当PHP作为Apache Web服务器的一部分时,运行代码不需要调外部二进制程序,服务器解释脚本不需要承担任何额外负担。
  *
分析XML -- 用户可以组建一个可以读取XML信息的PHP版本。
  *
数据库模块 -- 用户可以使用PHP存取OracleSybaseMS SQLAdabase DMySQLmSQLPostgreSQLdBaseFileProUnix dbmInformix/Illustra等类型的数据库,以及任何支持ODBC标准的数据库。
  *
文件存取--PHP有许多支持文件存取函数。
  *
文本处理--PHP有许多函数处理字符串,其中包括模式匹配的能力。
  *
复杂的变量--PHP支持标量、数组、关联数组等变量,这给用户提供了以支持其它的高级数据结构的坚实基础。
  *
图象处理--用户可以使用PHP动态的创建图象。
  *
更多的其它功能!
  
  1.3 PHP
需要花费多少钱?
  PHP
是免费的。所有的源码、文档都可以免费的复制、编译、打印和分发。用户的任何一个用PHP编写的程序都属于用户自己,可以按照自己的意愿进行处理,而不需要付任何版税。就PHP本身而言,用户可以无限制地发布自己编写的程序。
  
然而,有着很充分的理由,PHP并不是彻底的公共领域代码。如果PHP源码是完全的公共领域代码,很可能就有人对PHP的源码做很小的修改,然后编译并出售--换一句话说,从它的创作者中脱离出来。但从另一方面说,如果不公布源码,很难使想使用它的用户感到放心。
  GNU
通用公共许可是一种发布免费软件的方法,它可以避免其他人占有你的劳动成果。在符合GNU许可的条件下,源码可以自由地发布,并且任何一个人都可以使用,但是任何来源于此代码的程序必须以同样种类的许可方式发布。换句话说,如果用户从任何GNU许可下的源码中得到代码而编写自己的程序,用户必须给任何想得到源码的人共布自己的源码。
  1.4 PHP
语言可以嵌入HTML
  
当使用者使用经典程序设计语言(如CPascal)编程时,所有的代码必须编译成一个可执行的文件,然后该可执行文件在运行时,为远程的Web浏览器而产生可显示的HTML标记。但另一方面,PHP并不需要编译(至少不编译成可执行文件)。使用者可以把自己的代码混合到HTML中。例如,下面的代码将显示Hello,world!”PHP代码在下面以黑体字显示。
  
  
  Test
  
  
  

Hello,php echo $string ?>


  
  
  
  PHP应用程序服务器(本书的主要写作目的)是紧密集成到Apache Web服务器中的,可以在一个程序内同时调用它们两个。当Web浏览器请求PHP Web页面的时候,Web服务器的PHP部分将被调用进行解释。Web服务器在请求的Web页中寻找标记,并按要求执行这些PHP代码。
  
PHP代码生成的输出将替代标记。例如,当PHP代码运行后,以前的Web页面将变成如下所示的内容:
  
  
  Test
  
  

Hello,world!


  
  
  
  
注意,所有的PHP代码都消失了,仅仅留下了HTML语句。而由PHP代码生成的HTML语句在上例中以黑体的形式显示。
  
  1.5 PHP
语言是在Web服务器端运行
  
当开发互联网应用程序时,很重要的一点是要清楚应用程序是在哪一端运行的。PHP总是运行在服务器端。不要嘲笑对这一点的强调。在以后考虑对应用程序某些特性进行规划时,有的人可能就会在应用程序在哪里运行的这个问题上搞错,不要让自己也成为这些人中的一个。
  
由于Java appletsActiveX,或Javascript 都是运行在客户端的Web浏览器中的,因此PHP不能直接和它们进行比较。然而可以很容易的将这些语言与PHP相结合在一起,使用PHP可以很方便地生成所需要的任何HTML代码,当然也就能激活Java appletsActiveX控件,还可以动态生成Javascript语句。当对互联网应用程序开发还很陌生的时候,这也许没有什么意义,但是在读完这本书后,这一切就会变得十分清晰的了。
  1.6 PHP
无处不在
  
无处不在是常使用的充满激情的词语,到19997月,将有60万左右的Web站点使用PHP1999年夏天有关Linux和开放代码运动的大发展很可能使PHP团体有突破性发展。可以在http://www.php.net/usage.php3站点上看到它的发展趋势图表。
  
此外,PHP邮件列表每天能收到大约80个电子邮件,每个月能收到大约2500个电子邮件,这说明PHP是一个非常活跃的开发团体。使用PHP的商业公司有以下几个,Mitsubishi MotorsVolvoRed Hat SoftwareE*TradeFirst USA Bankthe San Francisco GiantsSan Diego Zoo等等。
  1.7 PHP
CJava相似吗?
  PHP
程序和C程序有略微相似的地方,这是由于PHP来源于CPerlJava。一些对C语言来讲比较麻烦的方面(如处理字符串的技术),由于采用了和Perl相近的技术,在PHP中就不再是麻烦了。PHP中也不包括Java中的一些面向对象特性。
  PHP
能很好地处理某些低级的任务,如果代码需要运行的特别快,可以很方便的使用CPHP程序编写模块。
  1.8 PHP
ColdFusionActive Server PageJava Server Page更好吗?
  
以流行的商议方式,我总是回答,可以是,也可以不是
  
回答是,是由于它的费用(免费)以及可以通过邮件列表、IRC而在世界范围内有广泛的支持网络。同时PHP还在不断地发展着,如果想要一个PHP现在没有的特性时,请等待几个月,就有人很快为PHP编程而加上此种特性。
  
回答不是,是由于商业软件有比PHP更多的特性。例如,Allaire's ColdFusion有一个已证实可靠的搜索引擎组件。微软的Active Server Page技术提供了与Outlook、电子邮件和工作组程序相结合的能力。Java Server Page让使用者可以使用互联网上的大量开放源码模块。
  1.9
总结
  
对于遍及互联网上的PHP,本章仅仅简要提到了它的一些特性,本章也介绍了当设计互联网应用程序时,PHP为什么是最好的编程工具之一的原因。
  
下一章安装PHP”将一步一步的介绍了PHP的编译过程、

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian PHP 8.4 Installation and Upgrade guide for Ubuntu and Debian Dec 24, 2024 pm 04:42 PM

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

How To Set Up Visual Studio Code (VS Code) for PHP Development How To Set Up Visual Studio Code (VS Code) for PHP Development Dec 20, 2024 am 11:31 AM

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c

7 PHP Functions I Regret I Didn't Know Before 7 PHP Functions I Regret I Didn't Know Before Nov 13, 2024 am 09:42 AM

If you are an experienced PHP developer, you might have the feeling that you’ve been there and done that already.You have developed a significant number of applications, debugged millions of lines of code, and tweaked a bunch of scripts to achieve op

How do you parse and process HTML/XML in PHP? How do you parse and process HTML/XML in PHP? Feb 07, 2025 am 11:57 AM

This tutorial demonstrates how to efficiently process XML documents using PHP. XML (eXtensible Markup Language) is a versatile text-based markup language designed for both human readability and machine parsing. It's commonly used for data storage an

Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Explain JSON Web Tokens (JWT) and their use case in PHP APIs. Apr 05, 2025 am 12:04 AM

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

PHP Program to Count Vowels in a String PHP Program to Count Vowels in a String Feb 07, 2025 pm 12:12 PM

A string is a sequence of characters, including letters, numbers, and symbols. This tutorial will learn how to calculate the number of vowels in a given string in PHP using different methods. The vowels in English are a, e, i, o, u, and they can be uppercase or lowercase. What is a vowel? Vowels are alphabetic characters that represent a specific pronunciation. There are five vowels in English, including uppercase and lowercase: a, e, i, o, u Example 1 Input: String = "Tutorialspoint" Output: 6 explain The vowels in the string "Tutorialspoint" are u, o, i, a, o, i. There are 6 yuan in total

Explain late static binding in PHP (static::). Explain late static binding in PHP (static::). Apr 03, 2025 am 12:04 AM

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? What are PHP magic methods (__construct, __destruct, __call, __get, __set, etc.) and provide use cases? Apr 03, 2025 am 12:03 AM

What are the magic methods of PHP? PHP's magic methods include: 1.\_\_construct, used to initialize objects; 2.\_\_destruct, used to clean up resources; 3.\_\_call, handle non-existent method calls; 4.\_\_get, implement dynamic attribute access; 5.\_\_set, implement dynamic attribute settings. These methods are automatically called in certain situations, improving code flexibility and efficiency.

See all articles