PHP and MySQL Tutorials - PHP
In this tutorial, we introduce the PHP scripting language. PHP is similar to high-level languages such as C, Perl, Pascal, FORTRAN, and Java, and programmers who have experience with any of these languages should have little trouble learning PHP. This tutorial serves as an introduction to PHP; it's not a programming guide. We assume you are already familiar with programming in a high-level language.
Table of content (tutorial index)
advertisement
PHP
PHP Basics
Creating PHP scripts
Outputting data with echo and print
String literals
Variables
Expressions, Operators, and Variable Assignment
Expressions
Type Conversion
Automatic type conversion
Examining Variable Type and Content
Testing, setting, and unsetting variables
if...else Statement
switch Statement
Conditional Expressions
while
for
Changing Loop Behavior
A Working Example
Creating Arrays
Associative arrays
Multidimensional arrays
Using foreach Loops with Arrays
Using Array Pointers
Counting elements in arrays
Finding values in arrays with in_array() and array_search()
Reordering elements in arrays with array_reverse()
Sorting with sort() and rsort()
Sorting associative arrays
Sorting on keys
Sorting with user-defined element comparison
String Literals
Variable substitution
Creating formatted output with sprintf() and printf()
Padding strings
Changing case
Trimming whitespace
Comparing Strings
Extracting a substring from a string
Finding the position of a substring
Extracting a found portion of a string
Extracting multiple values from a string
Replacing substrings
Translating characters and substrings
Regular Expression Syntax, Characters and wildcards
Character lists
Optional and repeating characters
Groups
Escaping special characters
Finding and extracting values
Replacing substrings
Generating a Timestamp
Creating timestamps with mktime() and gmmktime()
String to timestamp
Subsecond times
Formatting a Date
Validating a Date
Absolute Value
Ceiling and Floor
Number Systems
Basic Trigonometry Functions
Random Number Generation
User-Defined Functions
Variable Scope
Global variables
Passing arguments by reference
Assigning by reference
Reusing Functions with Include and Require Files
Classes and Objects
Inheritance
A Page That Produces Partial or No Output
Variable naming
Missing output
Complaints About Headers