PHP Tutorial
Recent Updates
  • PHP - $_SERVER
    $_SERVER $_SERVER is a PHP super global variable which holds information about headers, paths, and script locations. The example below shows how to use some of the elements in $_SERVER: ExampleGet your own PHP Server echo $_SERVER['PHP_SELF']; echo $_SERVER['SERVER_NAME']; echo $_SERVER['HTTP_HOST']; echo $_SERVER['HTTP_REFERER']; echo $_SERVER['HTTP_USER_AGENT']; echo...
    0 Comments 0 Shares 2143 Views 0 Reviews
  • PHP $GLOBALS
    $GLOBALS is an array that contains all global variables. Global Variables Global variables are variables that can be accessed from any scope. Variables of the outer most scope are automatically global variables, and can be used by any scope, e.g. inside a function. To use a global variable inside a function you have to either define them as global with the global keyword,...
    0 Comments 0 Shares 1967 Views 0 Reviews
  • PHP Global Variables - Superglobals
    Superglobals were introduced in PHP 4.1.0, and are built-in variables that are always available in all scopes. PHP Global Variables - Superglobals Some predefined variables in PHP are "superglobals", which means that they are always accessible, regardless of scope - and you can access them from any function, class or file without having to do anything special. The PHP superglobal variables...
    0 Comments 0 Shares 1890 Views 0 Reviews
  • PHP Array Functions
    PHP Array Functions PHP has a set of built-in functions that you can use on arrays. Function Description array() Creates an array array_change_key_case() Changes all keys in an array to lowercase or uppercase array_chunk() Splits an array into chunks of arrays array_column() Returns the values from a single column in the input array array_combine() Creates...
    1 Comments 0 Shares 1949 Views 0 Reviews
  • PHP Multidimensional Arrays
    In the previous pages, we have described arrays that are a single list of key/value pairs. However, sometimes you want to store values with more than one key. For this, we have multidimensional arrays. PHP - Multidimensional Arrays A multidimensional array is an array containing one or more arrays. PHP supports multidimensional arrays that are two, three, four, five, or more levels deep....
    0 Comments 0 Shares 1858 Views 0 Reviews
  • PHP Sorting Arrays
    The elements in an array can be sorted in alphabetical or numerical order, descending or ascending. PHP - Sort Functions For Arrays In this chapter, we will go through the following PHP array sort functions: sort() - sort arrays in ascending order rsort() - sort arrays in descending order asort() - sort associative arrays in ascending order, according to the value...
    0 Comments 0 Shares 1992 Views 0 Reviews
  • PHP Delete Array Items
    Remove Array Item To remove an existing item from an array, you can use the array_splice() function. With the array_splice() function you specify the index (where to start) and how many items you want to delete. ExampleGet your own PHP Server Remove the second item: $cars = array("Volvo", "BMW", "Toyota"); array_splice($cars, 1, 1); Try it Yourself » After...
    0 Comments 0 Shares 1900 Views 0 Reviews
  • PHP Add Array Items
    Add Array Item To add items to an existing array, you can use the bracket [] syntax. ExampleGet your own PHP Server Add one more item to the fruits array: $fruits = array("Apple", "Banana", "Cherry"); $fruits[] = "Orange"; Try it Yourself » Associative Arrays To add items to an associative array, or key/value array, use brackets [] for the key,...
    0 Comments 0 Shares 1938 Views 0 Reviews
  • PHP Update Array Items
    Update Array Item To update an existing array item, you can refer to the index number for indexed arrays, and the key name for associative arrays. ExampleGet your own PHP Server Change the second array item from "BMW" to "Ford": $cars = array("Volvo", "BMW", "Toyota"); $cars[1] = "Ford"; Try it Yourself » Note: The first item has index 0. To update items from...
    0 Comments 0 Shares 1913 Views 0 Reviews
  • PHP Access Arrays
    Access Array Item To access an array item, you can refer to the index number for indexed arrays, and the key name for associative arrays. ExampleGet your own PHP Server Access an item by referring to its index number: $cars = array("Volvo", "BMW", "Toyota"); echo $cars[2]; Try it Yourself » Note: The first item has index 0. To access items from an associative...
    0 Comments 0 Shares 1953 Views 0 Reviews
  • PHP Create Arrays
    Create Array You can create arrays by using the array() function: ExampleGet your own PHP Server $cars = array("Volvo", "BMW", "Toyota"); Try it Yourself » You can also use a shorter syntax by using the [] brackets: Example $cars = ["Volvo", "BMW", "Toyota"]; Try it Yourself » Multiple Lines Line breaks are not important, so an array...
    0 Comments 0 Shares 1796 Views 0 Reviews
  • PHP Associative Arrays
    PHP Associative Arrays Associative arrays are arrays that use named keys that you assign to them. ExampleGet your own PHP Server $car = array("brand"=>"Ford", "model"=>"Mustang", "year"=>1964); var_dump($car); Try it Yourself » Access Associative Arrays To access an array item you can refer to the key name. Example Display the model of the car: $car =...
    0 Comments 0 Shares 1834 Views 0 Reviews
More Stories