PHP Cert
Terms
undefined, object
copy deck
- General: Possible Values for a boolean
- "" = false,1 = ture
- Define a Constant
- define( $name, $value )
- Operator: !==
- value or type are different
-
Operator:
=== - value and type are the same
- Operator: Bitwise xor
- ^
- string concat
- .
- General: which one happens first ? = or --
- = happens BEFORE --
- break out of the current loop entirely
- break
- break out of the current iteration
- continue
- get number of arguments passed to a function
- func_num_args()
- return a function argument
- func_get_arg($argnum)
- call parent construct from child's constructor
- parent::base_class
- return an array containing all properties of an object
- __sleep()
- automatically load all of the properties from the array, but can be used to repopulate derived properties.
- __wakeup()
- General: How do create an array ferom form elements
- use var[]
- General: What is the basic proccess of cookies
-
1 Client sends request to server
2 Server sends response with Set-Cookie:
3 Client sends reqeust with Cookie:
4 Server sends a response - cookie attribute: restricts cookie's use to a given hostname
- domain
-
cookie attribute: date after the cookie should be removed
* Default? - expires, defaults to browser close.
- cookie attribute: restrict cookie's use to a given server-side path
- path
- cookie attribute: only transmit over SSL
- secure
-
must be called before $_SESSION[] used
* What is it doing behind the scenes -
session_start()
* Sets some HTTP headers - php.ini: where on the server to store session data
- (string) session.save_path
- php.ini: use cookies to propigate session id
- (bool) session.use_cookies
- php.ini: use cookies and NOT URL
- (bool) session.use_only_cookies
- php.ini: automatically call session_start()
- (bool) session.auto_start
- php.ini: Set the default expiration of a php.ini: cookie
- session.coookie_lifetime
- php.ini: set a given Set-Cookie var.
- session.cookie_[something]
- php.ini: Try to use cookie based sessions. If that doesn't work, use URL.
- (bool) session.use_trans_sid
- override session handling
- session_set_save_handler('myopen', 'myclose', 'myread', 'mywrite', 'mydelete', 'mygarbage');
- list: array key types
- strings, floats (truncated), bools or integers
- list: array value types
- strings, floats, integers, arrays, objects
- language construct: add a value to an array
- myarray[] = something
- create an array
- (array) array($key_value_pairs) (See above)
- break an array into individual vars
- (special) list($vars_to_populate) (See above)
- actuially returns an array of the current row
- (array) each($an_array) (See above)
- return the internal pointer to the first element in the array
- (mixed) reset($an_array) (See above)
- call a function for each element of an array
- (bool) array_walk($an_array, $str_func_name)
- returns the number of elements in array (non array vars return 1, null returns 0)
- (int) count($an_array)
- returns an array conatining the keys of another
- (array) array_keys($an_array)
- true if an element with said key exists in said array
- (bool) is_set($an_array[$some_element])
- same as is_set, but faster
- (bool) array_key_exists($an_array, $some_element
- returns a recased array
- (array) array_change_key_case($an_array, CASE_UPPER|CASE_LOWER)
- returns 1 or more random keys
- (scaler/array) array_rand($an_array, [$no_of_elements=1])
- sort $arr asc. by keys
- (bool) ksort($arr, [SORT_REGULAR|SORT_NUMERIC|SORT_STRING])
- sort $arr desc. by keys
- (bool) krsort($arr, [SORT_REGULAR|SORT_NUMERIC|SORT_STRING])
- same as ksort with values insetad of keys but keys replaced by default (0,1,2...)
- (bool) sort()/rsort()
- same as ksort with values insetad of keys. Keys are maintained
- (bool) asort()/arsot()
- randomly sort an array
- (bool) shuffle($an_array)
- merges 2 or more arrays. numeric keys are renumbered. When keys numeric, duplicates keys are renumbered and added to the end of the merged array. When duplicate string keys are present only the instance from the last array will be present.
- array) array_merge($a, $b, [...$n])
- same as array_merge() except duplicate values are added as array values for their respective keys.
- (array) array_merge_recursive
- outputs an array where each element value is common in the array. key values ignored in match, but leftmost is kept in new array.
- (array) array_intersect($a, $b, [...$n])
- outputs an array where each key/value pair is common between all arrays.
- (array) array_intersect_assoc($a, $b, [...$n])
- Same as array_intersect(), except only unique elements are retained
- (array) array_diff($a, $b, [...$n])
- Same as array_intersect_assoc(), except only unique elements are retained
- (array) array_diff_assoc($a, $b, [...$n])
- return a string representation of the given array.
- (string) serialize($an_array)
- return an array from a serialized string.
- (array) unserialize($string)
- Sort an array and its subarrays
- (bool) array_multisort($array[$x], [SORT_ASC|SORT_DESC], [SORT_REGULAR|SORT_NUMERIC|SORT_STRING], $array[$y], [SORT_ASC|SORT_DESC], [SORT_REGULAR|SORT_NUMERIC|SORT_STRING], [...]
- Compares two strings. Returns 0 if equal, -1 if $str_a comes when sorted alphabetically, 1 if $str_a comes second
- (bool) strcmp($str_a, $str_b)
- Same as strcmp(), but case insensitive
- (bool) strcasecmp($str_a, $str_b)
- Same as strcmp(), but compares only first $n chars
- (bool) strncmp($str_a, $str_b, $n)
- Same as strcasecmp(), but compares only first $n chars
- (bool) strncasecmp($str_a, $str_b, $n)
- sorts an array, using the given function for comparasin
- (bool) usort($an_array, $sort_func)
- seaches a string for a substring, returns matched string or false
- ($substr|false) strstr($str_to_serach, $substr)
- same as strstr() but case insensitive
- ($substr|false) stristr($str_to_search, $substr)
- seaches a string for a substring, returns offset or false
- (int|false) strpos($str_to_serach, $substr)
- same as strpos(), but case insensitive
- (int|false) stripos($str_to_serach, $substr)
- same as strstr(), strpos(), and stripos(), but they find the last instance.
- strrchr(), strrpos(), strripos()
- print a formatted string (See next section)
- printf($format_string, $arg_1, [$arg_n])
- same as printf() but with an array
- vprintf($format_string, $arg_array)
- same as printf() but returns the string
- (string) sprintf()
- same as vprintf() but returns the string
- vsprintf()
- same as printf() but to a stream.
- fprintf($stream, $format_string, $arg_1, [$arg_n])
- get part of a string
- (string) substr($string, $start_offset, [$length])
- return $string, formated by printf style $format_string
- (array) sscanf($string, $format_string)
- replace a substring in a given string, strating with an offset.
- (string) substr_replace($string, $replace_with, $start_offset, [$length])
- search and replace in a string.
- (string) str_replace($str_search, $str_replace, $str_subject)
- same as str_replace() but case insensitive
- str_ireplace()
- check if a string matches a pattern, put matches in $ary_matches
- bool) preg_match($pattern, $str_to_search, [$ary_matches])
- like preg_match(), but returns a 2d array of all matches from each occurance of the given pattern
- (bool) preg_match_all()
- replace pattern in string with another string. Use \1, \2, etc. to denote pattern elements.
- (string) preg_replace($pattern, $replace_with, $subject)
- splits a string into an array using a static delimiter
- (array) explode( $delim, $subject )
- splits a string into an array using a regexp
- (array) preg_split( $pattern, $subject )
- like preg_split() but uses a POSIX regexp
- split()
- open the specified file with a given mode
- (resource) fopen( $filename, $mode )
- check if we are at the end of the given file
- (bool) feof( $resource )
- read from the specified file. Returns a string of the given length
- (string) fread( $resource, $len_in_bytes )
- read a line from the given file
- (string/false) fgets( $resource )
- output the remainder of the given file. Outputs number of chars read, or false on error
- (int/false) fpassthru( $resource )
- close a file
- fclose( $resource )
- write a string to a file. returns bytes writen or false on error
- (int/false) fwrite( $resource, $string, [$length] )
- flush output to a file
- (bool) fflush( $resource )
- get stats about a file
- (array) fstat( $resource )
- same as fstat, but takes a filename rather than resource
- (array) stat( $filename )
- copy a file
- (bool) copy( $src, $dest )
- delete a file
- (bool) unlink( $filename )
- move/rename a file
- (bool) rename( $old_name, $new_name )
- change the owner of a file
- (bool) chown( $filename, $user )
- change the group of a file
- (bool) chgrp( $filename, $group )
- change the mode of a file. Mode is ocatal
- (bool) chmod( $filename, $mode )
- Lock a file with a shared, exclusive lock, or unlock it. LOCK_NB will create non-blocking lock that will return false if file is locked.
- (bool) flock( $resource, LOCK_SH|LOCK_EX|LOCK_UN|LOCK_NB )
- read a file into an array of lines
- (array) file( $filename )
- output the contents of a file. Return chars read
- (int) readfile( $filename )
- read the contents of file into a string
- (string) get_file_contents( $filename )
- puts the file pointer at the begining of the file
- (bool) rewind( $resource )
- return true if file exists
- (bool) file_exists($filename)
- return access time of file
- (int) fileatime($filename)
- return change time of file
- (int) filectime($filename)
- return modify time of file
- (int) filemtime($filename)
- return groupid of file
- (int) filegroup($filename)
- return inode of file
- (int) fileinode($filename)
- return userid of file
- (int) fileowner($filename)
- return mode of file
- (int) fileperms($filename)
- return size of file
- (int) filesize($filename)
- return type of file. 'inode', 'file', 'dir', etc.
- (string) filetype($filename)
- retruns true if file is directory
- (bool) is_dir($filename)
- retruns true if file is executable
- (bool) is_executable($filename)
- retruns true if file is regular file
- (bool) is_file($filename)
- retruns true if file is soft link
- (bool) is_line($filename)
- retruns true if file is readable
- (bool) is_readable($filename)
- retruns true if file was just uploaded via HTTP
- (bool) is_uploaded_file($filename)
- retruns true if file is writable
- (bool) is_writable($filename)
- return the current unix timestamp
- (int) time()
- return a precisce timestamp: * Elements
- (array) gettimeofday() * => sec = current timestamp => usec = microseconds past sec => minuteswest = minutes offset from UTC (west of Greenwich) => dst = bool denotes daylight savings
- return current date array, or that of a unix timestamp
- (array) getdate( [$unix_timestamp] )
- same as getdate(), but array is indexed; month is 0-11; year is years since 1900. Sencond paramter is 1 for an associative array
- (array) localtime( [$unix_timestamp], $associative )
- retrun a formated version of a timestamp
- (string) date( $format, [$unix_timestamp] )
- return a formated (C-Style) version of timestamp. Works with setlocale()
- (string) strftime( $format, [$unix_timestamp )
- Same as strftime(), but uses UTC/GMT timezone
- (string) gmstrftime()
- Get a unix timestamp for a date
- (int) mktime( [$hour], [$minute], [$sec], [$month], [$day], [$year], [$dst] )
- Same asmktime(), but uses UTC/GMT timezone
- (string) gmmktime()
- Set the locale. Returns new one.
- (string/false) setlocale(LC_TIME, $locale_string )
- gets a unix timestamp form a string. -1 flags an error
- (int) strtotime($time_string)
- send a mail message
- (bool) mail( $to, $subject, $message, $more_headers, $extra_sendmail_params)
- split a string into chunks, (usually for base64 encoding
- (string) chunk_split( $body, [$chunk_size], [$chunk_end] )
- encode a string in base64
- (string) base64_encode ( $data )