X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

PHP Examples


PHP Syntax

Write text to the output using PHP
Add comments in PHP
User-defined functions, classes, and keywords ARE NOT case-sensitive
Variable names ARE case-sensitive

Examples explained


PHP Variables

Create different variables
Test local (inside function) and global (outside function) scope
Use the global keyword to access a global variable from within a function
Use the $GLOBALS[] array to access a global variable from within a function
Use the static keyword to let a local variable not be deleted after execution of function

Examples explained


PHP Echo and Print

Display strings with the echo command
Display strings and variables with the echo command
Display strings with the print command
Display strings and variables with the print command

Examples explained


PHP Data Types

PHP strings
PHP integers
PHP floating point numbers
PHP arrays
PHP objects
PHP NULL value

Examples explained


PHP String Functions

strlen() - Return the length of a string, in characters
strpos() - Search for a specified character or text within a string

Examples explained


PHP Constants

Create a case-sensitive constant
Create a case-insensitive constant

Examples explained


PHP Operators

Arithmetic operators
Assignment operators
String operators
Increment/Decrement operators
Comparison operators
Array operators

Examples explained


PHP If...Else and Switch Statements

The if statement
The if...else statement
The if...elseif...else statement
The switch statement

Examples explained


PHP While and For Loops

The while loop
The do...while loop
Another do...while loop
The for loop
The foreach loop

Examples explained


PHP Functions

Create a function
Function with one argument
Function with two arguments
Function with default argument value
Function that returns a value

Examples explained


PHP Arrays

Indexed arrays
count() - Return the length of an array
Loop through an indexed array
Associative arrays
Loop through an associative array

Examples explained


PHP Sorting Arrays

sort() - Sort array in ascending alphabetical order
sort() - Sort array in ascending numerical order
rsort() - Sort array in descending alphabetical order
rsort() - Sort array in descending numerical order
asort() - Sort array in ascending order, according to value
ksort() - Sort array in ascending order, according to key
arsort() - Sort array in descending order, according to value
krsort() - Sort array in descending order, according to key

Examples explained


PHP Superglobals

$GLOBAL - Used to access global variables from anywhere in the PHP script
$_SERVER - Holds information about headers, paths, and script locations
$_REQUEST - Used to collect data after submitting an HTML form
$_POST - Used to collect form data after submitting an HTML form. Also used to pass variables
$_GET - Collect data sent in the URL

Examples explained


PHP Form Validation

Complete code for PHP Form Validation

Example explained



Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook