PHP
PHP教程 | PHP论坛 | PHP中文手册

Search for

第 2 章 简明教程

目录

需要些什么?
第一个 PHP 页面
实用的脚本
处理表单
在新版本的 PHP 中使用旧的 PHP 代码
下一步做什么?

本章将给出关于 PHP 的简明教程。虽然 PHP 的功能并不局限于生成动态的 web 页面,但本章的内容仅涉及于此。请查阅“PHP 能做什么”一节以获取更多信息。

使用了 PHP 的 web 页面将被和通常的 HTML 页面一样处理,可以用通常建立 HTML 页面的方法来建立和编辑它们。

需要些什么?

在本教程中,假设用户的服务器已经安装并运行了 PHP,所有以 .php 结尾的文件都将由 PHP 来处理。在大部分的服务器上,这是 PHP 的默认扩展名,不过,也请询问服务器管理员以确认。如果服务器支持 PHP,则不需要做任何事情。只用建立 .php 文件,并把它们放置到 web 目录中,服务器将神奇地自动解析这些文件。不用编译任何东西,也不用安装任何其它的工具,仅仅只需把这些使用了 PHP 的文件想象成简单的 HTML 文件,其中只不过多了一种新的标识符,在这里可以做各种各样的事情。大多数的 web 主机都提供 PHP 的支持,如果你的主机不支持,可以访问 » PHP 相关链接来查找支持 PHP 的 web 主机。

假设用户希望在本地机器开发以节约宝贵的带宽。在这种情况下,需要安装一个诸如 » Apache 的 web 服务器,当然还有 » PHP。可能还希望安装一个数据库,例如 » MySQL

可以一个个的安装它们或选择一个更简单的方法。可以参考本手册中 PHP 安装说明的相关章节(假设已经配置好了某个 web 服务器)。若在自己安装 PHP 时出现了问题,建议在» 安装邮件列表中询问。如果想使用更简便的方法安装 PHP,那么可以考虑» 获取一个预先配置的安装包,用这个安装包,只用点击几下鼠标,就可以自动地安装所有这些系统。在任何操作系统下建立有 PHP 支持的 web 服务器都十分简单,包括 MacOSX、Linux 和 Windiws。在 Linux 下,会发现 » rpmfind» PBone 能够在获取 RPM 时提供帮助。也可以使用 » apt-get 搜索 Debian 的相关软件包。



User Contributed Notes 简明教程
Rob (Freefallfire at gmail dot com)
07-Apr-2007 08:54
On the note of fast and easy developer setup's, Xampp is of particular note. If you're interested, just Google 'Xampp' ... It is a product from the Apache Friends group and includes the Apache web server, PHP and Perl along with some other interesting modules, Filezilla ftp server and MySQL. All within one installer, making it a very usefull and broad developers or learners platform.
Michael
02-Mar-2007 05:54
Agreed. Some of the pre-configured packs and associated tutorials really can simplify the installation and get you up and running in minutes but you MUST make sure that as an absolute minimum you add a secure password - ideally a mix of letters, numbers, not a real word etc. Otherwise, when your site/system is live, it will be potentially open to abuse.
cvncpu
26-Oct-2006 02:53
just keep in mind that these installation packages are for development use, and are not built for a production enviroment, the preformance and security of these tools is not setup for use in a public website.

 
PHP教程 | PHP论坛 | PHP中文手册