PHP Tutorials - Herong's Tutorial Examples
Dr. Herong Yang, Version 3.10

PHP Tutorials - Herong's Tutorial Examples

http://www.herongyang.com/PHP

Copyright © 2012 by Dr. Herong Yang. All rights reserved.

This free PHP tutorial book is a collection of notes and sample codes written by the author while he was learning PHP himself. It can be used as a tutorial guide for beginners or a reference book for experienced developers. Topics include PHP, array, CGI, CLI, session, cookie, database, directory, file, HTTP, header lines, IIS, image, mail, MySQL, redirect, request, response, SMTP, SOAP, SOAP Extension, SQL, Unicode, WSDL.

Table of Contents

About This PHP Tutorial Book

Introduction and Installation of PHP 5.4.3

What Is PHP?

Downloading and Installing PHP 5.4.3 for Windows

"php -help" - Command Line Options

"php -m" - Built-in Modules

"php -i" - PHP Engine Information

Hello.php - My First PHP Script

PHP Script File Syntax

PHP Script Source Code File Format

PHP Script Processing Rules

PHP Statement Delimiter and Comments

PHP Data Types and Data Literals

Data Types Supported in PHP

Data Literals Supported in PHP

Data Literals Examples for Integer, String and Other Data Types

Overflow of Integer and Float Values

Variables, References, and Constants

Variables and Assignment Operations

References and Variables

Variable Variable Name - Name Variables with Expressions

Constant and define() Function

Expressions, Operations and Type Conversions

What Is an Expression?

What Is an Operation?

Precedence of Operations

Data Type Automatic Conversion

Conditional Statements - "if" and "switch"

"if" Statements

"if" Statement Examples

"switch" Statements

"switch" Statement Examples

Loop Statements - "while", "for", and "do ... while"

"while" Statements

"while" Statement Examples

"for" Statements

"for" Statement Examples

"do ... while" Statements

"break" and "continue" Statements

Function Declaration, Arguments, and Return Values

What Is a Function?

"function" Statements - Defining Functions

Function Call Operations

Passing Arguments to Functions

Example of Passing Arguments by Values

Using Pass-by-Value Arguments for References

Example of Passing Arguments by References

Variable-Length Argument Lists

Providing Default Values to Argument Variables

Returning Values from Functions

Returning References from Functions

Arrays - Ordered Maps

What Is an Array?

Creating Arrays - Examples

Array Related Built-in Functions

Configuring and Sending out Emails

Using Local Windows System as a Mail Server

Sending Out Emails from PHP Scripts

Retrieving Information from HTTP Requests

Predefined Variables Related to HTTP Requests

Operating System Information in $_SERVER

Web Server Information in $_SERVER

Information in $_GET and $_REQUEST

Registering $_REQUEST Keys as Global Variables

Creating and Managing Sessions in PHP Scripts

What Is a Session?

How Sessions Are Support in PHP?

SessionPage*.php - Session Test Script Pages

Running Session Test Script Pages

Managing Session IDs without Cookies

Where Is Session Data Stored?

Sending and Receiving Cookies in PHP Scripts

What Is a Cookie?

Sending and Receiving Cookies

Sending and Receiving Cookies - Example

ob_start() - Output Buffering Function

Persistent Cookies Saved on Hard Disk

Other Cookie Properties - Domain and Path

Controlling HTTP Response Header Lines in PHP Scripts

What Is an HTTP Response?

HTTP Response Header Lines

header() - Inserting a Raw Header Lines

HttpRequestGet.php - Viewing Header Lines

Response Header Lines of Static Files

HttpHeaderLines.php - Examples of Inserting Header Lines

Location: - Forcing the Browser to Redirect to Another URL

Content-Type: - Generating Non-HTML Response Body

Content-Disposition: - Sending Files for Downloading

MySQL Server Connection and Access Functions

Configuring PHP for MySQL Server Access

mysql_connect() and Other MySQL Functions

MySqlLoop.php - MySQL Functions Test

Functions to Manage Directories, Files and Images

opendir() and Directory Management Functions

file_exists() and File Testing Functions

FileExistsTest.php - File Testing Examples

fopen() and File Input/Output Functions

File_Input_Output_Test.php - File Input/Output Examples

readfile() and Special File Handling Functions

imagecreatetruecolor() and GD Imaging Library Functions

ShowPhoto.php - Simple Slid Show Script

SOAP Extension Function and Calling Web Services

PHP Implementations of SOAP

Turning on the Default SOAP Extension

Get_Temperature.php - First Example of SOAP

SoapClient - SOAP Client Class and Functions

Get_Temperature_Dump.php - Dumping Debugging Information

What Is WSDL?

Using SOAP Extension in non-WSDL Mode

SOAP Server Functions and Examples

SoapServer - SOAP Server Class and Functions

HelloServer.php - First SOAP Server Application

HelloServer12.php - First SOAP 1.2 Server Application

HelloServerWsdl.php - SOAP 1.2 Server Application in WSDL Mode

Localization Overview of Web Applications

What Is Localization / Internationalization?

Localization of Web Based Applications

Character String Traveling Paths

Output ASCII Character Strings from PHP Scripts

Using Non-ASCII Characters in HTML Documents

Basic Rules of Using Non-ASCII Characters in HTML Documents

French Characters in HTML Documents - UTF-8 Encoding

French Characters in HTML Documents - ISO-8859-1 Encoding

Chinese Characters in HTML Documents - UTF-8 Encoding

Chinese Characters in HTML Documents - GB2312 Encoding

Characters of Multiple Languages in HTML Documents

Using Non-ASCII Characters as PHP Script String Literals

Basic Rules of Using Non-ASCII Characters in HTML Documents

French Characters in String Literals - UTF-8 Encoding

French Characters in HTML Documents - ISO-8859-1 Encoding

Chinese Characters in String Literals - UTF-8 Encoding

Chinese Characters in String Literals - GB2312 Encoding

Characters of Multiple Languages in String Literals

Receiving Non-ASCII Characters from Input Forms

Basic Rules of Receiving Non-ASCII Characters from Input Forms

Receiving Non-ASCII Characters with GET Method

Receiving Non-ASCII Characters with POST Method

Receiving Non ASCII Characters in UTF-8 Encoding

Decoding HTML Entities

"mbstring" Extension and Non-ASCII Encoding Management

"mbstring" - Multi-Byte String Extension

mb_convert_encoding() and Other mbstring Functions

Examples of Using "mbstring" Functions

Managing HTTP Input and Output Encoding

Managing Non-ASCII Character Strings with MySQL Servers

Storing Non-ASCII Characters in Database

Transmitting Non-ASCII Characters with Database

MySqlUnicode.php - MySQL Unicode UTF-8 Encoding Example

Outdated Tutorials

Outdated: Downloading and Installing PHP 5.0.4 for Windows

Outdated: Downloading and Installing PHP 5.2.2 for Windows

Outdated: Adding PHP to IIS as CGI

References

PDF Printing Version

Keywords: PHP, Tutorial, Examples, Web

Previous Version: http://www.herongyang.com/PHP/index2.html

Dr. Herong Yang, updated in 2012
Table of Contents