PHP Superglobals and Functions Flashcards
contains information about the
server environment and the current request
$_SERVER
contains any data that was sent to the
script through a GET request.
$_GET
contains any data that was sent to the
script through a POST request.
$_POST
contains any uploaded files that were
sent to the script through a POST request. This superglobal is
used when handling file uploads.
$_FILES
superglobal contains any cookies that were
sent to the script by the client browser.
$_COOKIE
contains any session variables
that have been set
$_SESSION
superglobal contains the contents of $_GET,
$_POST, and $_COOKIE.
$_REQUEST
contains any environment variables
that have been set on the server.
$_ENV
superglobal contains all global variables
that have been defined in the script. It can be used to
access variables from within a function or other local
scope.
$GLOBALS
function is used to find the length of a string.
strlen()
function is used to replace a string with
another string.
str_replace()
function is used to count the number of
elements in an array.
count()
function is used to add one or more
elements to the end of an array.
array_push()
function is used to remove the last
element from an array.
array_pop()
function is used to format a date and time.
Syntax: date(format, timestamp)
date()
DATE FUNCTION
function is used to convert a string into a
Unix timestamp.strtotime()
strtotime()
Date Function
function is used to calculate the difference
between two dates.
date_diff()
DATE FUNCTION
function is used to return the absolute value of
a number.
abs()
function is used to raise a number to a power.
pow()
function is used to generate a random number.
rand()
function is used to establish a
connection with a MySQL database.
Syntax: mysqli_connect(servername, username,
password, dbname)
mysqli_connect()
function is used to execute a SQL query
mysqli_query()
function is used to fetch a result
row as an associative array from a MySQL query. The
function takes a result object returned by mysqli_query().
mysqli _ fetch _ assoc()
function is used to get the
number of rows in a result set returned by a MySQL
query. The function takes a result object returned by
mysqli_query().
mysqli _ num _ rows()
function is used to close a MySQL
database connection.
mysqli_close()
is used to check if a variable is set
and not null.
isset()
function is used to check if a variable is
empty.
empty()
function is used to display the type and
value of a variable.
var_dump()
The settype() function is used to set the type of a variable.
settype()
function is used to convert a variable to an
integer.
intval()
function is used to remove whitespace or other
characters from the beginning and end of a string.
trim()