🐘

PHP Cheatsheet

Basics

<?php ... ?>
PHP code block
echo
Output one or more strings
$variable
Variable declaration
// or #
Single-line comment

Arrays

array()
Creates an array
count()
Returns the number of elements in an array
sort()
Sorts an array in ascending order
array_push()
Inserts one or more elements to the end of an array

Superglobals

$_GET
Collects data sent in the URL
$_POST
Collects data from an HTML form
$_SESSION
Variables available to all pages in one session
$_SERVER
Information about headers, paths, and script locations