0% found this document useful (0 votes)
203 views

PHP Cheatsheet

This document provides a cheat sheet of common PHP functions organized into categories including MySQL functions, string functions, array functions, classes and objects, variable handling functions, filesystem functions, regular expressions, SQLite3 functions, and function handling functions. It lists the main functions for each category and includes brief descriptions and notes.

Uploaded by

Adjoa GodChild
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
203 views

PHP Cheatsheet

This document provides a cheat sheet of common PHP functions organized into categories including MySQL functions, string functions, array functions, classes and objects, variable handling functions, filesystem functions, regular expressions, SQLite3 functions, and function handling functions. It lists the main functions for each category and includes brief descriptions and notes.

Uploaded by

Adjoa GodChild
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

PHP CHEAT SHEET BY DANIEL AT HTTP://WWW.DANIELDEV.

EU

Mysql functions
mysql_connect($link, $usr, $pwd) mysql_close() mysql_select_db($db) mysql_db_query($db, $query) mysql_list_dbs() mysql_drop_db($dbName) mysql_list_tables($database) mysql_tablename(resource, $int) mysql_query($query) mysql_num_fields(resource) mysql_num_rows(resource) mysql_fetch_array(resource) mysql_fetch_assoc(resource) mysql_fetch_row(resource) mysql_real_escape_string($str) mysql_error()

String functions
substr_replace($str, search, pos) strstr($haystack, $needle) strlen($str) strpos($haystack, $needle) strip_tags($str) htmlentities($str) htmlspecialchars($str) trim($str) also: rtrim/ltrim implode($glue, arr $pieces) addslashes($str) nl2br($str) crypt($str, [$salt])

Array functions
is_array($var) array_keys(array) array_combine(arr_keys, arr_val) array_diff(arr1, arr2, arr3 ..) array_merge(arr1, arr2, ..) array_push(array, $var) array_reverse(array) array_shift(array) array_walk(array, funcName)

Classes and objects


class_exists($className) method_exists($obj, $method) property_exists($class, $prop) get_class_methods($class_n) get_class_vars($className) get_class([$obj]) get_declared_classes() get_parent_class([$obj]) get_object_vars($obj) ob_start() ob_clean() ob_flush() flush() ob_get_clean() ob_get_flush() ob_end_flush() ob_get_contents() ob_get_lenght() ob_get_status() ob_implicit_flush() ob_list_handlers()

Varible handling func


empty($var) floatval($var) get_defined_vars() get_resource_type($handler) is_array($var) is_binary($var) is_buffer($var) is_null($var) is_object($var) is_string($var) isset($var) also: unset serialize($val) also: unserialize settype($var, $type) strval($var) var_dump($var)

PostgreSQL Functions
pg_connect($conn) pg_connection_reset($conn) pg_pconnect($conn) pg_close([$conn]) pg_fetch_all(resource) pg_fetch_all_columns(resource) pg_fetch_array(resource) pg_fetch_assoc(resource) pg_fetch_object(resource) pg_fetch_row(resource) pg_select($conn, $table, $arr) * pg_insert($conn, $table, $arr) * pg_query([$conn], $query) pg_cancel_query($conn) pg_affected_rows(resource) pg_num_fields(resource) pg_num_rows(resource) pg_ping([$conn]) pg_field_type(resource, $fieldNr) pg_result_error(resource)

Output control

Filesystem functions
fopen($filename, mode) fclose($handler) fread($handler, $len) fwrite($handler, $str) file_exists($filename) file_get_contents($filename) filetype($filename) filesize($filename) is_executable($filename) is_dir($filename) chmod($file, mode) copy($source, $dest) dirname($path)

Regex perl compatible


preg_match(pat, subj) preg_match_all(pat, subj, match) preg_replace(pat, replace, subj) preg_split(pat, subj) preg_filter(pat, replace, subj) preg_grep(pat, input) preg_last_error()
Notes:

SQLitet3 Functions
SQLite3::changes() SQLite3::close() SQLite3::_construct($filename) SQLite3::escapeString($val) SQLite3::exec($query) SQLite3::lastErrorCode() SQLite3::lastErrorMsg() SQLite3::lastInsertRowID() SQLite3::loadExtension($lib) SQLite3::open($filename) SQLite3::prepare($query) SQLite3::query($query) SQLite3::querySingle($query)

Function handling
func_get_arg($arg_num) func_get_args() func_num_args() function_exists($funcName) get_defined_functions()

* the current function is experimental at the time of this writting. [ ] detonates optional parameters.

You might also like