PHP Examples
This section contains a brief collection of examples demonstrating the various PHP functions and its features in real action.
PHP Basic
- PHP "Hello World!" application
- Embedding PHP within HTML
- PHP single line comments
- PHP multi-line comments
- Creating variables in PHP
- Case sensitivity of PHP variable names
PHP Data Types
- PHP integers
- PHP strings
- PHP floating point numbers or doubles
- PHP booleans
- PHP arrays
- PHP objects
- PHP NULL
- PHP resources
PHP Echo and Print
- Display strings of text with the echo statement
- Display HTML code with the echo statement
- Display variables with the echo statement
- Display strings of text with the print statement
- Display HTML code with the print statement
- Display variables with the print statement
PHP Strings
- Differences between single and double quoted strings
- Find the length of a string
- Replacing text within a string
- Reversing the direction of a string
PHP Operators
- PHP arithmetic operators
- PHP assignment operators
- PHP comparison operators
- PHP incrementing and decrementing operators
- PHP logical operators
- PHP string operators
- PHP array operators
PHP If...Else and Switch Statements
- PHP if Statement
- PHP if...else Statement
- PHP if...elseif...else Statement
- PHP Switch...Case Statements
PHP Arrays
- PHP indexed arrays
- PHP associative arrays
- PHP multidimensional array
- Viewing array structure and values
- Get complete array information
PHP Sorting Arrays
- Sorting indexed arrays in alphabetically ascending order
- Sorting indexed arrays in numerically ascending order
- Sorting indexed arrays in alphabetically descending order
- Sorting indexed arrays in numerically descending order
- Sorting associative arrays in ascending order by value
- Sorting associative arrays in descending order by value
- Sorting associative arrays in ascending order by key
- Sorting associative arrays in descending order by key
PHP Loops
PHP Functions
- Creating a function
- PHP functions with parameters
- PHP functions with optional parameters and default values
- PHP functions returning values
PHP Date and Time
- Get current date
- Formatting the dates
- Formatting the times
- Get current time as timestamp
- Convert timestamp to human readable date and time
- Create timestamp from specific date and time
- Get weekday name from timestamp
- Get future date
More PHP Examples
For more examples on PHP, please check out the PHP tutorial section step by step.