You are on page 1of 1

!"#$!

%&&
'()$" *$%+#,-% (!.$/"%#0 1"0+!,2#,-%
addslashes ( str) Escapes quotes (' and ") with backslashes (\)
echo / print ( str1, ...) Outputs one or more strings
explode ( separator, str, limit) Splits str into an array of strings with given separator
htmlentities ( str, quote_style, charset) Converts all possible characters to HTML entities
htmlspecialchars ( str, quote_style, charset) Converts &, <, >, ", and ' to HTML entities
implode ( gIue, array) Joins array into a string with glue between elements
md5 ( str, raw_output) Calculates the MD5 hash of a string
nl2br ( str, is_xhtml) Inserts <br /> or <br> before all newlines in the string
number_format ( num, decimals, dpoint, tsep) Formats numwith 1,000s and number of decimals
printf ( format, vaIue1, ...) Outputs a formatted string
str_ireplace ( nd, repI, subj, &count) Case-insensitive version of str_replace
str_pad ( str, Iength, padding, type) Pads str to specied length with spaces or padding
str_replace ( nd, repI, subj, &count) Replaces nd with repl in subj (strings, or arrays of)
stripos ( haystack, needIe, offset) Case-insensitive version of strpos
stripslashes ( str) Un-quotes a quoted string
stristr ( haystack, needIe, before_needle) Case-insensitive version of strstr
strlen ( str) Returns the length of str in bytes
strpos ( haystack, needIe, offset) Finds offset of rst needle in haystack, or FALSE
strstr ( haystack, needIe, before_needle) Extracts haystack substring fromrst needle to end
strtolower ( str) Converts all characters in str to lowercase
strtoupper ( str) Converts all characters in str to uppercase
substr ( str, start, length) Returns substring fromstart with optional max. length
trim ( str, charlist) Strips whitespace or given characters fromends of str
wordwrap ( str, width, break, cut) Word wraps str to given number of characters per line
STRING FUNCTIONS
phpmaster.com/guide
PHP comes loaded with many core functions
for PHP novice or ninja alike to exploit.
Here are just some of the more useful ones.
Included is information on the functions
parameters or arguments, a description of
what the function does, and the datatype of
its return value.
So the reference to
means the function str_pad returns a string
and takes four possible arguments: a string,
an integer, an optional (italics) string and an
optional integer.
Go to php.net for further information on
argument values, not to mention loads more
handy PHP built-in functions.
!"#$!%&&
'()$" *$%+#,-% (!.$/"%#0 1"0+!,2#,-%
array_lter ( array, callback) Filters out items where callback doesnt return true
array_ip ( array) Flips array, so values become keys and vice versa
array_keys ( array, value, strict) Returns all array keys, or keys for an element value
array_key_exists ( key, array) Checks if the given key exists in the array
array_merge ( array1, array2, ...) Merges multiple arrays, or renumbers a single array
array_pop ( &array) Removes and returns the last element fromthe array
array_push ( &array, value1, M ...) Adds one or more elements; returns the new count
array_rand ( array, count) Picks one or count randomkeys fromthe array
array_reverse ( array, preserve_keys) Returns an array with elements in reverse order
array_search ( needIe, haystack, strict) Returns rst key for needle in haystack, or FALSE
array_slice ( array, offset, length, preserve) Extracts sub-array, optionally preserving keys
array_unique ( array, hags) Copies array without duplicate values
array_walk ( array, caIIback, userdata) For each array element, callback(value, key, userdata)
arsort ( &array, hags) Sorts array values in reverse order, maintains keys
asort ( &array, hags) Sorts array values in order, maintains keys
count ( array, mode) Counts elements in array, with optional recursion
in_array ( needIe, haystack, strict) Returns TRUE if needle is a value in haystack
krsort ( &array, hags) Sorts array keys in reverse order
ksort ( &array, hags) Sorts array keys
rsort ( &array, hags) Sorts array values in reverse order, discards keys
sort ( &array, hags) Sorts array values, discards keys
ARRAY FUNCTIONS
!"#$!%&&
'()$" *$%+#,-% (!.$/"%#0 1"0+!,2#,-%
basename ( path, sufhx) Gets lename out of full path, strips sufx
copy ( source, dest) Copies source lename to dest lename
dirname ( path) Gets directory name out of full path
fclose ( handIe) Closes an open le, freeing it up for use
feof ( handIe) Returns TRUE if pointer is at end of le
fgets ( handIe, length) Reads one line fromle pointer
le_exists ( Iename) Checks whether a le or directory exists
le_get_contents ( Iename, incpath, cntx, offs, len) Reads entire le or part thereof into string
le_put_contents ( Iename, data, hags, cntx) Writes a string or array of strings to a le
le ( Iename, incpath, cntx) Reads entire le into an array
lesize ( Iename) Gets le size in bytes
fopen ( Iename, mode, incpath, cntx) Gets handle to read and/or write le/URL
fpassthru ( handIe) Outputs le contents frompointer
fread ( handIe, Iength) Reads up to length bytes fromle
fwrite ( handIe, S string, length) Writes string (or only length bytes) to le
is_dir ( Iename) Returns TRUE if lename is a directory
is_uploaded_le ( Iename) Veries that le was uploaded by POST
move_uploaded_le ( Iename, dest) Moves le to dest if uploaded by POST
readle ( Iename, incpath, cntx) Outputs le contents
realpath ( path) Returns absolute le path for given path
rename ( oIdname, newname, cntx) Renames a le or directory
tempnam ( dir, prex) Creates unique lename in dir with prex
touch ( Iename, time, atime) Sets modication and access time of le
unlink ( Iename, cntx) Deletes a le
FILE FUNCTIONS
!"#$!%&&
'()$" *$%+#,-% (!.$/"%#0 1"0+!,2#,-%
get_include_path () Gets the current PHP include path
get_magic_quotes_gpc () Determines whether Magic Quotes feature is enabled
ini_set ( option, newvaIue) Sets a PHP option for this script
phpinfo ( what) Outputs detailed PHP conguration information
restore_include_path () Restores PHP include path to initial value
set_include_path ( incIude_path) Temporarily sets the PHP include path for this request
set_time_limit ( seconds) Sets the max. time for this script to run (default 30 sec.)
PHP CONFIGURATION FUNCTIONS
FURTHER INFORMATION
PHP
BUILT-IN
FUNCTIONS
NOVICE TO NINJA
str_pad ( str, length, padding, type) Pads str to spe...
LEGEND
Array
Boolean
Float
Integer
Mixed
Resource
String
Void
Arguments that appear
in italics are optional

You might also like