PHP Tutorials - Herong's Tutorial Examples

https://www.herongyang.com/PHP

© 2003-2024 Herong Yang. All rights reserved.

PHP Tutorials This PHP tutorial book is a collection of notes and sample codes written by the author while he was learning PHP himself. Topics include PHP script syntax; data types, variables, array, expressions, statements and functions; Web server integration; HTTP requests and controlling HTTP responses; sessions, cookies, and file uploads/downloads; files, directories; classes and objects; using PHP on Windows, macOS and Linux; executing external programs on operating system. Updated in 2024 (Version v5.18) with minor changes.

Table of Contents

About This Book

Introduction and Installation of PHP

What Is PHP

Downloading and Installing PHP 7.3 for Windows

"php -help" - Command Line Options

"php -m" - Built-in Modules

"php -i" - PHP Engine Information

php.ini - PHP Runtime Configuration

Hello.php - My First PHP Script

"php -a" - PHP Interactive Shell

Downloading and Installing PHP Documentation

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

Arrays - Ordered Maps

What Is an Array

Creating Arrays - Examples

Array Related Built-in Functions

Usage Examples of Array Functions

Interface with Operating System

$argv[] - Command Line Arguments

Options to Execute External Programs

`command` - Backtick Operator

exec() - Execute External Programs

system() - Execute External Programs

passthru() - Execute External Programs

popen() - Execute External Programs

proc_open() - Execute External Programs

memory_get_usage() - Memory Usage Info

set_time_limit() - max_execution_time

Introduction of Class and Object

What Is a Class

What Is an Object

What Is a Constructor

What Is a Static Method

What Is a Static Variable

What Is a Superclass and a Subclass

What Is an Abstract Class

What Is an Abstract Method

What Is an Interface

What Is a Trait

What Is an Overloaded Property

What Is an Overloaded Method

What Is Object Property Iteration

What Is Object Cloning

What Is Object Serialization

What Is in an Object Variable

Updating Variables Who Share an Object

Passing Objects as Function Arguments

Integrating PHP with Apache Web Server

Downloading Apache 2.4.37 Binary for Windows

Installing Apache 2.4.37 on Windows Systems

Publishing HTML Documents as Web Pages

Starting and Stopping Apache Server

Configuring Apache for PHP CGI Scripts

Publishing PHP Scripts as Web Pages

Permission Error on php-cgi.exe

Configuring Apache PHP Load Module

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 Supported 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

Managing File Upload

File Upload Web Form

File Upload PHP Script

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

ShowPhoto.php - Simple Slid Show Script

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

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

Configuring and Sending Out Emails

Using Local Windows System as a Mail Server

Sending Out Emails from PHP Scripts

Sending Out Emails on Linux Systems

Install PHPMailer on CentOS Systems

Send Local Emails with PHPMailer

Send Remote Emails with PHPMailer

Use SMTPS Protocol with PHPMailer

PHP 5.6 and PHPMailer 5.2

Install PHPMailer from Source Code

Managing PHP Engine and Modules on macOS

PHP Version Pre-Installed on macOS

Upgrade PHP Engine on macOS

Managing PHP Engine and Modules on CentOS

PHP Version Pre-Installed on CentOS

Install PHP Extensions on CentOS

PHP Version Pre-Installed on CentOS 6

Use PHP Composer on CentOS Computers

Archived Tutorials

Archived: Downloading and Installing PHP 7.0 for Windows

Archived: Downloading and Installing PHP 5.6.6 for Windows

Archived: Downloading and Installing PHP 5.4.3 for Windows

Archived: Downloading and Installing PHP 5.2.2 for Windows

Archived: Downloading and Installing PHP 5.0.4 for Windows

Archived: Adding PHP to IIS as CGI

Archived: Downloading Apache HTTP Server 2.4.12 for Windows

Archived: Installing Apache HTTP Server 2.4.12 on Windows

Archived: Publishing PHP Scripts as Web Pages

Archived: Configuration for php_mysql.dll Library

Archived: mysql_connect() using php_mysql.dll Library

Archived: MySqlLoop.php using php_mysql.dll Library

Archived: Get_Temperature.php - First Example of SOAP

Archived: Get_Temperature_Dump.php - Dumping Debugging Information

Archived: MySqlUnicode.php using php_mysql.dll Library

References

Full Version in PDF/EPUB

Keywords: PHP, Tutorial, Examples, Web