Form JS | PHP Functions

https://www.php.net/manual/en/refs.compression.php

Affecting PHP's Behaviour

APCu Functions

  1. apcu_add — Cache a new variable in the data store
  2. apcu_cache_info — Retrieves cached information from APCu's data store
  3. apcu_cas — Updates an old value with a new value
  4. apcu_clear_cache — Clears the APCu cache
  5. apcu_dec — Decrease a stored number
  6. apcu_delete — Removes a stored variable from the cache
  7. apcu_enabled — Whether APCu is usable in the current environment
  8. apcu_entry — Atomically fetch or generate a cache entry
  9. apcu_exists — Checks if entry exists
  10. apcu_fetch — Fetch a stored variable from the cache
  11. apcu_inc — Increase a stored number
  12. apcu_key_info — Get detailed information about the cache key
  13. apcu_sma_info — Retrieves APCu Shared Memory Allocation information
  14. apcu_store — Cache a variable in the data store

APCUIterator — The APCUIterator class

  1. APCUIterator::__construct — Constructs an APCUIterator iterator object
  2. APCUIterator::current — Get current item
  3. APCUIterator::getTotalCount — Get total count
  4. APCUIterator::getTotalHits — Get total cache hits
  5. APCUIterator::getTotalSize — Get total cache size
  6. APCUIterator::key — Get iterator key
  7. APCUIterator::next — Move pointer to next item
  8. APCUIterator::rewind — Rewinds iterator
  9. APCUIterator::valid — Checks if current position is valid

Blenc Functions

  1. blenc_encrypt — Encrypt a PHP script with BLENC

------------------------------------------

Componere (latin, English: compose) targets production environments and provides an API for composition of classes, monkey patching, and casting.

  1. Componere\Abstract\Definition — The Componere\Abstract\Definition class
    1. Componere\Abstract\Definition::addInterface — Add Interface
    2. Componere\Abstract\Definition::addMethod — Add Method
    3. Componere\Abstract\Definition::addTrait — Add Trait
    4. Componere\Abstract\Definition::getReflector — Reflection
  2. Componere\Definition — The Componere\Definition class
    1. Componere\Definition::__construct — Definition Construction
    2. Componere\Definition::addConstant — Add Constant
    3. Componere\Definition::addProperty — Add Property
    4. Componere\Definition::register — Registration
    5. Componere\Definition::isRegistered — State Detection
    6. Componere\Definition::getClosure — Get Closure
    7. Componere\Definition::getClosures — Get Closures
  3. Componere\Patch — The Componere\Patch class
    1. Componere\Patch::__construct — Patch Construction
    2. Componere\Patch::apply — Application
    3. Componere\Patch::revert — Reversal
    4. Componere\Patch::isApplied — State Detection
    5. Componere\Patch::derive — Patch Derivation
    6. Componere\Patch::getClosure — Get Closure
    7. Componere\Patch::getClosures — Get Closures
  4. Componere\Method — The Componere\Method class
    1. Componere\Method::__construct — Method Construction
    2. Componere\Method::setPrivate — Accessibility Modification
    3. Componere\Method::setProtected — Accessibility Modification
    4. Componere\Method::setStatic — Accessibility Modification
    5. Componere\Method::getReflector — Reflection
  5. Componere\Value — The Componere\Value class
    1. Componere\Value::__construct — Value Construction
    2. Componere\Value::setPrivate — Accessibility Modification
    3. Componere\Value::setProtected — Accessibility Modification
    4. Componere\Value::setStatic — Accessibility Modification
    5. Componere\Value::isPrivate — Accessibility Detection
    6. Componere\Value::isProtected — Accessibility Detection
    7. Componere\Value::isStatic — Accessibility Detection
    8. Componere\Value::hasDefault — Value Interaction
  6. Componere Functions
    1. Componere\cast — Casting
    2. Componere\cast_by_ref — Casting

---------------------------------

Error Handling Functions

  1. debug_backtrace — Generates a backtrace
  2. debug_print_backtrace — Prints a backtrace
  3. error_clear_last — Clear the most recent error
  4. error_get_last — Get the last occurred error
  5. error_log — Send an error message to the defined error handling routines
  6. error_reporting — Sets which PHP errors are reported
  7. restore_error_handler — Restores the previous error handler function
  8. restore_exception_handler — Restores the previously defined exception handler function
  9. set_error_handler — Sets a user-defined error handler function
  10. set_exception_handler — Sets a user-defined exception handler function
  11. trigger_error — Generates a user-level error/warning/notice message
  12. user_error — Alias of trigger_error

--------------------------------

FFI — Main interface to C code and data

  1. FFI::addr — Creates an unmanaged pointer to C data
  2. FFI::alignof — Gets the alignment
  3. FFI::arrayType — Dynamically constructs a new C array type
  4. FFI::cast — Performs a C type cast
  5. FFI::cdef — Creates a new FFI object
  6. FFI::free — Releases an unmanaged data structure
  7. FFI::isNull — Checks whether a FFI\CData is a null pointer
  8. FFI::load — Loads C declarations from a C header file
  9. FFI::memcmp — Compares memory areas
  10. FFI::memcpy — Copies one memory area to another
  11. FFI::memset — Fills a memory area
  12. FFI::new — Creates a C data structure
  13. FFI::scope — Instantiates an FFI object with C declarations parsed during preloading
  14. FFI::sizeof — Gets the size of C data or types
  15. FFI::string — Creates a PHP string from a memory area
  16. FFI::type — Creates an FFI\CType object from a C declaration
  17. FFI::typeof — Gets the FFI\CType of FFI\CData
  18. FFI\CData — C Data Handles
  19. FFI\CType — C Type Handles
  20. FFI\Exception — FFI Exceptions
  21. FFI\ParserException — FFI Parser Exceptions

------------------------------------------

OPcache improves PHP performance by storing precompiled script bytecode in shared memory, thereby removing the need for PHP to load and parse scripts on each request.
OPcache Functions

  1. opcache_compile_file — Compiles and caches a PHP script without executing it
  2. opcache_get_configuration — Get configuration information about the cache
  3. opcache_get_status — Get status information about the cache
  4. opcache_invalidate — Invalidates a cached script
  5. opcache_is_script_cached — Tells whether a script is cached in OPCache
  6. opcache_reset — Resets the contents of the opcode cache

----------------------------------------

The Output Control functions allow you to control when output is sent from the script. This can be useful in several different situations, especially if you need to send headers to the browser after your script has begun outputting data. The Output Control functions do not affect headers sent using header() or setcookie(), only functions such as echo and data between blocks of PHP code.

Output Control Functions
  1. flush — Flush system output buffer
  2. ob_clean — Clean (erase) the output buffer
  3. ob_end_clean — Clean (erase) the output buffer and turn off output buffering
  4. ob_end_flush — Flush (send) the output buffer and turn off output buffering
  5. ob_flush — Flush (send) the output buffer
  6. ob_get_clean — Get current buffer contents and delete current output buffer
  7. ob_get_contents — Return the contents of the output buffer
  8. ob_get_flush — Flush the output buffer, return it as a string and turn off output buffering
  9. ob_get_length — Return the length of the output buffer
  10. ob_get_level — Return the nesting level of the output buffering mechanism
  11. ob_get_status — Get status of output buffers
  12. ob_gzhandler — ob_start callback function to gzip output buffer
  13. ob_implicit_flush — Turn implicit flush on/off
  14. ob_list_handlers — List all output handlers in use
  15. ob_start — Turn on output buffering
  16. output_add_rewrite_var — Add URL rewriter values
  17. output_reset_rewrite_vars — Reset URL rewriter values

----------------------------------------------

PHP Options/Info:

This functions enable you to get a lot of information about PHP itself, e.g. runtime configuration, loaded extensions, version and much more. You'll also find functions to set options for your running PHP. The probably best known function of PHP - phpinfo() - can be found here.

PHP Options/Info Functions

  1. assert_options — Set/get the various assert flags
  2. assert — Checks if assertion is false
  3. cli_get_process_title — Returns the current process title
  4. cli_set_process_title — Sets the process title
  5. dl — Loads a PHP extension at runtime
  6. extension_loaded — Find out whether an extension is loaded
  7. gc_collect_cycles — Forces collection of any existing garbage cycles
  8. gc_disable — Deactivates the circular reference collector
  9. gc_enable — Activates the circular reference collector
  10. gc_enabled — Returns status of the circular reference collector
  11. gc_mem_caches — Reclaims memory used by the Zend Engine memory manager
  12. gc_status — Gets information about the garbage collector
  13. get_cfg_var — Gets the value of a PHP configuration option
  14. get_current_user — Gets the name of the owner of the current PHP script
  15. get_defined_constants — Returns an associative array with the names of all the constants and their values
  16. get_extension_funcs — Returns an array with the names of the functions of a module
  17. get_include_path — Gets the current include_path configuration option
  18. get_included_files — Returns an array with the names of included or required files
  19. get_loaded_extensions — Returns an array with the names of all modules compiled and loaded
  20. get_magic_quotes_gpc — Gets the current configuration setting of magic_quotes_gpc
  21. get_magic_quotes_runtime — Gets the current active configuration setting of magic_quotes_runtime
  22. get_required_files — Alias of get_included_files
  23. get_resources — Returns active resources
  24. getenv — Gets the value of an environment variable
  25. getlastmod — Gets time of last page modification
  26. getmygid — Get PHP script owner's GID
  27. getmyinode — Gets the inode of the current script
  28. getmypid — Gets PHP's process ID
  29. getmyuid — Gets PHP script owner's UID
  30. getopt — Gets options from the command line argument list
  31. getrusage — Gets the current resource usages
  32. ini_alter — Alias of ini_set
  33. ini_get_all — Gets all configuration options
  34. ini_get — Gets the value of a configuration option
  35. ini_restore — Restores the value of a configuration option
  36. ini_set — Sets the value of a configuration option
  37. main — Dummy for main
  38. memory_get_peak_usage — Returns the peak of memory allocated by PHP
  39. memory_get_usage — Returns the amount of memory allocated to PHP
  40. php_ini_loaded_file — Retrieve a path to the loaded php.ini file
  41. php_ini_scanned_files — Return a list of .ini files parsed from the additional ini dir
  42. php_sapi_name — Returns the type of interface between web server and PHP
  43. php_uname — Returns information about the operating system PHP is running on
  44. phpcredits — Prints out the credits for PHP
  45. phpinfo — Outputs information about PHP's configuration
  46. phpversion — Gets the current PHP version
  47. putenv — Sets the value of an environment variable
  48. restore_include_path — Restores the value of the include_path configuration option
  49. set_include_path — Sets the include_path configuration option
  50. set_time_limit — Limits the maximum execution time
  51. sys_get_temp_dir — Returns directory path used for temporary files
  52. version_compare — Compares two "PHP-standardized" version number strings
  53. zend_thread_id — Returns a unique identifier for the current thread
  54. zend_version — Gets the version of the current Zend engine

----------------------------------------------

Implemented as a SAPI module, phpdbg can exert complete control over the environment without impacting the functionality or performance of your code.

phpdbg aims to be a lightweight, powerful, easy to use debugging platform for PHP. It offers the following features:

  1. Step-Through Debugging
  2. Flexible Breakpoints (Class Method, Function, File:Line, Address, Opcode)
  3. Easy Access to PHP with built-in eval()
  4. Userland API
  5. SAPI Agnostic - Easily Integrated
  6. PHP Configuration File Support
  7. JIT Super Globals - Set Your Own !!
  8. Optional readline Support - Comfortable Terminal Operation
  9. Easy Operation - See Help :)

phpdbg Functions

  1. phpdbg_break_file — Inserts a breakpoint at a line in a file
  2. phpdbg_break_function — Inserts a breakpoint at entry to a function
  3. phpdbg_break_method — Inserts a breakpoint at entry to a method
  4. phpdbg_break_next — Inserts a breakpoint at the next opcode
  5. phpdbg_clear — Clears all breakpoints
  6. phpdbg_color — Sets the color of certain elements
  7. phpdbg_end_oplog — Description
  8. phpdbg_exec — Attempts to set the execution context
  9. phpdbg_get_executable — Description
  10. phpdbg_prompt — Sets the command prompt
  11. phpdbg_start_oplog — Description

-------------------------------------------

The runkit7 extension provides means to modify constants, user-defined functions, and user-defined classes. It also provides for custom superglobal variables.

This package is a fork of the » runkit package providing PHP 7 support.

runkit7 Functions

  1. runkit7_constant_add — Similar to define(), but allows defining in class definitions as well
  2. runkit7_constant_redefine — Redefine an already defined constant
  3. runkit7_constant_remove — Remove/Delete an already defined constant
  4. runkit7_function_add — Add a new function, similar to create_function
  5. runkit7_function_copy — Copy a function to a new function name
  6. runkit7_function_redefine — Replace a function definition with a new implementation
  7. runkit7_function_remove — Remove a function definition
  8. runkit7_function_rename — Change a function's name
  9. runkit7_import — Process a PHP file importing function and class definitions, overwriting where appropriate
  10. runkit7_method_add — Dynamically adds a new method to a given class
  11. runkit7_method_copy — Copies a method from class to another
  12. runkit7_method_redefine — Dynamically changes the code of the given method
  13. runkit7_method_remove — Dynamically removes the given method
  14. runkit7_method_rename — Dynamically changes the name of the given method
  15. runkit7_object_id — Return the integer object handle for given object
  16. runkit7_superglobals — Return numerically indexed array of registered superglobals
  17. runkit7_zval_inspect — Returns information about the passed in value with data types, reference counts, etc

-------------------------------------------

The uopz - User Operations for Zend - extension exposes Zend Engine functionality normally used at compilation and execution time in order to allow modification of the internal structures that represent PHP code, and for user code to interact with the VM.

uopz supports the following activities:

  1. Overloading some opcodes including ZEND_EXIT and ZEND_NEW
  2. Backup and restore functions and methods
  3. Renaming functions and methods
  4. Copying of functions and methods
  5. Deletion of functions and methods
  6. Redefinition of global and class constants
  7. Deletion of global and class constants
  8. Runtime composition and modification of classes

Uopz Functions

  1. uopz_add_function — Adds non-existent function or method
  2. uopz_allow_exit — Allows control over disabled exit opcode
  3. uopz_backup — Backup a function
  4. uopz_compose — Compose a class
  5. uopz_copy — Copy a function
  6. uopz_del_function — Deletes previously added function or method
  7. uopz_delete — Delete a function
  8. uopz_extend — Extend a class at runtime
  9. uopz_flags — Get or set flags on function or class
  10. uopz_function — Creates a function at runtime
  11. uopz_get_exit_status — Retrieve the last set exit status
  12. uopz_get_hook — Gets previously set hook on function or method
  13. uopz_get_mock — Get the current mock for a class
  14. uopz_get_property — Gets value of class or instance property
  15. uopz_get_return — Gets a previous set return value for a function
  16. uopz_get_static — Gets the static variables from function or method scope
  17. uopz_implement — Implements an interface at runtime
  18. uopz_overload — Overload a VM opcode
  19. uopz_redefine — Redefine a constant
  20. uopz_rename — Rename a function at runtime
  21. uopz_restore — Restore a previously backed up function
  22. uopz_set_hook — Sets hook to execute when entering a function or method
  23. uopz_set_mock — Use mock instead of class for new objects
  24. uopz_set_property — Sets value of existing class or instance property
  25. uopz_set_return — Provide a return value for an existing function
  26. uopz_set_static — Sets the static variables in function or method scope
  27. uopz_undefine — Undefine a constant
  28. uopz_unset_hook — Removes previously set hook on function or method
  29. uopz_unset_mock — Unset previously set mock
  30. uopz_unset_return — Unsets a previously set return value for a function

------------------------------------------

Weak references provide a non-intrusive gateway to ephemeral objects. Unlike normal (strong) references, weak references do not prevent the garbage collector from freeing that object. For this reason, an object may be destroyed even though a weak reference to that object still exists. In such conditions, the weak reference seamlessly becomes invalid.

  1. WeakRef — The WeakRef class
    1. Weakref::acquire — Acquires a strong reference on that object
    2. Weakref::__construct — Constructs a new weak reference
    3. Weakref::get — Returns the object pointed to by the weak reference
    4. Weakref::release — Releases a previously acquired reference
    5. Weakref::valid — Checks whether the object referenced still exists
  2. WeakMap — The WeakMap class
    1. WeakMap::__construct — Constructs a new map
    2. WeakMap::count — Counts the number of live entries in the map
    3. WeakMap::current — Returns the current value under iteration
    4. WeakMap::key — Returns the current key under iteration
    5. WeakMap::next — Advances to the next map element
    6. WeakMap::offsetExists — Checks whether a certain object is in the map
    7. WeakMap::offsetGet — Returns the value pointed to by a certain object
    8. WeakMap::offsetSet — Updates the map with a new key-value pair
    9. WeakMap::offsetUnset — Removes an entry from the map
    10. WeakMap::rewind — Rewinds the iterator to the beginning of the map
    11. WeakMap::valid — Returns whether the iterator is still on a valid map element

-------------------------------------------------

Windows Cache Extension for PHP is a PHP accelerator that is used to increase the speed of PHP applications running on Windows and Windows Server. Once the Windows Cache Extension for PHP is enabled and loaded by the PHP engine, PHP applications can take advantage of the functionality without any code modifications.

The Windows Cache Extension includes 5 different types of caches. The following describes the purpose of each cache type and the benefits it provides.

  1. PHP Opcode Cache - PHP is a script processing engine, which reads an input stream of data that contains text and/or PHP instructions and produces another stream of data, most commonly in the HTML format. This means that on a web server the PHP engine reads, parses, compiles and executes a PHP script each time that it is requested by a Web client. The reading, parsing and compilation operations put additional load on the web server's CPU and file system and thus affect the overall performance of a PHP web application. The PHP bytecode (opcode) cache is used to store the compiled script bytecode in shared memory so that it can be re-used by PHP engine for subsequent executions of the same script.

    Support for opcode caching was removed in Wincache 2.0.0, all users who wish to have an opcache should use the OPcache extension that is included with PHP as of PHP 5.5.0.

  2. File Cache - Even with the PHP opcode cache enabled, the PHP engine has to accesses the script files on a file system. When PHP scripts are stored on a remote UNC file share, the file operations introduce a significant performance overhead. The Windows Cache Extension for PHP includes a file cache that is used to store the content of the PHP script files in shared memory, which reduces the amount of file system operations performed by PHP engine.

  3. Resolve File Path Cache - PHP scripts very often include or operate with files by using relative file paths. Every file path has to be normalized to an absolute file path by the PHP engine. When a PHP application uses many PHP files and accesses them by relative paths, the operation of resolving the paths may negatively impact the application's performance. The Windows Cache Extension for PHP provides a Resolve File Path cache, which is used to store the mappings between relative and absolute file paths, thereby reducing the number of path resolutions that the PHP engine has to perform.

  4. User Cache (available since version 1.1.0) - PHP scripts can take advantage of the shared memory cache by using the user cache API's. PHP objects and variables can be stored in the user cache and then re-used on subsequent requests. This can be used to improve performance of PHP scripts and to share the data across multiple PHP processes.

  5. Session Handler (available since version 1.1.0) - The WinCache session handler can be used to store the PHP session data in the shared memory cache. This avoids file system operations for reading and writing session data, which improves performance when large amount of data is stored in PHP session.

  1. WinCache Functions
    1. wincache_fcache_fileinfo — Retrieves information about files cached in the file cache
    2. wincache_fcache_meminfo — Retrieves information about file cache memory usage
    3. wincache_lock — Acquires an exclusive lock on a given key
    4. wincache_ocache_fileinfo — Retrieves information about files cached in the opcode cache
    5. wincache_ocache_meminfo — Retrieves information about opcode cache memory usage
    6. wincache_refresh_if_changed — Refreshes the cache entries for the cached files
    7. wincache_rplist_fileinfo — Retrieves information about resolve file path cache
    8. wincache_rplist_meminfo — Retrieves information about memory usage by the resolve file path cache
    9. wincache_scache_info — Retrieves information about files cached in the session cache
    10. wincache_scache_meminfo — Retrieves information about session cache memory usage
    11. wincache_ucache_add — Adds a variable in user cache only if variable does not already exist in the cache
    12. wincache_ucache_cas — Compares the variable with old value and assigns new value to it
    13. wincache_ucache_clear — Deletes entire content of the user cache
    14. wincache_ucache_dec — Decrements the value associated with the key
    15. wincache_ucache_delete — Deletes variables from the user cache
    16. wincache_ucache_exists — Checks if a variable exists in the user cache
    17. wincache_ucache_get — Gets a variable stored in the user cache
    18. wincache_ucache_inc — Increments the value associated with the key
    19. wincache_ucache_info — Retrieves information about data stored in the user cache
    20. wincache_ucache_meminfo — Retrieves information about user cache memory usage
    21. wincache_ucache_set — Adds a variable in user cache and overwrites a variable if it already exists in the cache
    22. wincache_unlock — Releases an exclusive lock on a given key


---------------------------------

XHProf is a light-weight hierarchical and instrumentation based profiler. During the data collection phase, it keeps track of call counts and inclusive metrics for arcs in the dynamic callgraph of a program. It computes exclusive metrics in the reporting/post processing phase, such as wall (elapsed) time, CPU time and memory usage. A functions profile can be broken down by callers or callees. XHProf handles recursive functions by detecting cycles in the callgraph at data collection time itself and avoiding the cycles by giving unique depth qualified names for the recursive invocations.

XHProf includes a simple HTML based user interface (written in PHP). The browser based UI for viewing profiler results makes it easy to view results or to share results with peers. A callgraph image view is also supported.

XHProf reports can often be helpful in understanding the structure of the code being executed. The hierarchical nature of the reports can be used to determine, for example, what chain of calls led to a particular function getting called.

XHProf supports ability to compare two runs (a.k.a. "diff" reports) or aggregate data from multiple runs. Diff and aggregate reports, much like single run reports, offer "flat" as well as "hierarchical" views of the profile.

Additional documentation can be found via the » facebook xhprof website.

Xhprof Functions

  1. xhprof_disable — Stops xhprof profiler
  2. xhprof_enable — Start xhprof profiler
  3. xhprof_sample_disable — Stops xhprof sample profiler
  4. xhprof_sample_enable — Start XHProf profiling in sampling mode

---------------------------------

Yac (Yet Another cache), is a lock-free, shared memory user data cache, could be used to replace APC, local memcache.

Yac — The Yac class

  1. Yac::add — Store into cache
  2. Yac::__construct — Constructor
  3. Yac::delete — Remove items from cache
  4. Yac::dump — Dump cache
  5. Yac::flush — Flush the cache
  6. Yac::get — Retrieve values from cache
  7. Yac::__get — Getter
  8. Yac::info — Status of cache
  9. Yac::set — Store into cache
  10. Yac::__set — Setter

----------------------------------

Platform independent audio bindings. Requires the » OpenAL library.

  1. openal_buffer_create — Generate OpenAL buffer
  2. openal_buffer_data — Load a buffer with data
  3. openal_buffer_destroy — Destroys an OpenAL buffer
  4. openal_buffer_get — Retrieve an OpenAL buffer property
  5. openal_buffer_loadwav — Load a .wav file into a buffer
  6. openal_context_create — Create an audio processing context
  7. openal_context_current — Make the specified context current
  8. openal_context_destroy — Destroys a context
  9. openal_context_process — Process the specified context
  10. openal_context_suspend — Suspend the specified context
  11. openal_device_close — Close an OpenAL device
  12. openal_device_open — Initialize the OpenAL audio layer
  13. openal_listener_get — Retrieve a listener property
  14. openal_listener_set — Set a listener property
  15. openal_source_create — Generate a source resource
  16. openal_source_destroy — Destroy a source resource
  17. openal_source_get — Retrieve an OpenAL source property
  18. openal_source_pause — Pause the source
  19. openal_source_play — Start playing the source
  20. openal_source_rewind — Rewind the source
  21. openal_source_set — Set source property
  22. openal_source_stop — Stop playing the source
  23. openal_stream — Begin streaming on a source

------------------------------

This package is based on the libradius (Remote Authentication Dial In User Service) of FreeBSD. It allows clients to perform authentication and accounting by means of network requests to remote servers.

This PECL extension adds full support for Radius Authentication (» RFC 2865) and Radius Accounting (» RFC 2866). This package is available for Unix (tested on FreeBSD and Linux) and for Windows.

  1. radius_acct_open — Creates a Radius handle for accounting
  2. radius_add_server — Adds a server
  3. radius_auth_open — Creates a Radius handle for authentication
  4. radius_close — Frees all ressources
  5. radius_config — Causes the library to read the given configuration file
  6. radius_create_request — Create accounting or authentication request
  7. radius_cvt_addr — Converts raw data to IP-Address
  8. radius_cvt_int — Converts raw data to integer
  9. radius_cvt_string — Converts raw data to string
  10. radius_demangle_mppe_key — Derives mppe-keys from mangled data
  11. radius_demangle — Demangles data
  12. radius_get_attr — Extracts an attribute
  13. radius_get_tagged_attr_data — Extracts the data from a tagged attribute
  14. radius_get_tagged_attr_tag — Extracts the tag from a tagged attribute
  15. radius_get_vendor_attr — Extracts a vendor specific attribute
  16. radius_put_addr — Attaches an IP address attribute
  17. radius_put_attr — Attaches a binary attribute
  18. radius_put_int — Attaches an integer attribute
  19. radius_put_string — Attaches a string attribute
  20. radius_put_vendor_addr — Attaches a vendor specific IP address attribute
  21. radius_put_vendor_attr — Attaches a vendor specific binary attribute
  22. radius_put_vendor_int — Attaches a vendor specific integer attribute
  23. radius_put_vendor_string — Attaches a vendor specific string attribute
  24. radius_request_authenticator — Returns the request authenticator
  25. radius_salt_encrypt_attr — Salt-encrypts a value
  26. radius_send_request — Sends the request and waits for a reply
  27. radius_server_secret — Returns the shared secret
  28. radius_strerror — Returns an error message

----------------------------

ncurses (new curses) is a free software emulation of curses in System V Rel 4.0 (and above). It uses terminfo format, supports pads, colors, multiple highlights, form characters and function key mapping. Because of the interactive nature of this library, it will be of little use for writing Web applications, but may be useful when writing scripts meant using PHP from the command line.

The features available, such as colors, depend on the terminal that you are using. Use functions such as ncurses_has_colors()ncurses_can_change_color(), and ncurses_has_ic() to check for individual capabilities.

  1. ncurses_addch — Add character at current position and advance cursor
  2. ncurses_addchnstr — Add attributed string with specified length at current position
  3. ncurses_addchstr — Add attributed string at current position
  4. ncurses_addnstr — Add string with specified length at current position
  5. ncurses_addstr — Output text at current position
  6. ncurses_assume_default_colors — Define default colors for color 0
  7. ncurses_attroff — Turn off the given attributes
  8. ncurses_attron — Turn on the given attributes
  9. ncurses_attrset — Set given attributes
  10. ncurses_baudrate — Returns baudrate of terminal
  11. ncurses_beep — Let the terminal beep
  12. ncurses_bkgd — Set background property for terminal screen
  13. ncurses_bkgdset — Control screen background
  14. ncurses_border — Draw a border around the screen using attributed characters
  15. ncurses_bottom_panel — Moves a visible panel to the bottom of the stack
  16. ncurses_can_change_color — Checks if terminal color definitions can be changed
  17. ncurses_cbreak — Switch off input buffering
  18. ncurses_clear — Clear screen
  19. ncurses_clrtobot — Clear screen from current position to bottom
  20. ncurses_clrtoeol — Clear screen from current position to end of line
  21. ncurses_color_content — Retrieves RGB components of a color
  22. ncurses_color_set — Set active foreground and background colors
  23. ncurses_curs_set — Set cursor state
  24. ncurses_def_prog_mode — Saves terminals (program) mode
  25. ncurses_def_shell_mode — Saves terminals (shell) mode
  26. ncurses_define_key — Define a keycode
  27. ncurses_del_panel — Remove panel from the stack and delete it (but not the associated window)
  28. ncurses_delay_output — Delay output on terminal using padding characters
  29. ncurses_delch — Delete character at current position, move rest of line left
  30. ncurses_deleteln — Delete line at current position, move rest of screen up
  31. ncurses_delwin — Delete a ncurses window
  32. ncurses_doupdate — Write all prepared refreshes to terminal
  33. ncurses_echo — Activate keyboard input echo
  34. ncurses_echochar — Single character output including refresh
  35. ncurses_end — Stop using ncurses, clean up the screen
  36. ncurses_erase — Erase terminal screen
  37. ncurses_erasechar — Returns current erase character
  38. ncurses_filter — Set LINES for iniscr() and newterm() to 1
  39. ncurses_flash — Flash terminal screen (visual bell)
  40. ncurses_flushinp — Flush keyboard input buffer
  41. ncurses_getch — Read a character from keyboard
  42. ncurses_getmaxyx — Returns the size of a window
  43. ncurses_getmouse — Reads mouse event
  44. ncurses_getyx — Returns the current cursor position for a window
  45. ncurses_halfdelay — Put terminal into halfdelay mode
  46. ncurses_has_colors — Checks if terminal has color capabilities
  47. ncurses_has_ic — Check for insert- and delete-capabilities
  48. ncurses_has_il — Check for line insert- and delete-capabilities
  49. ncurses_has_key — Check for presence of a function key on terminal keyboard
  50. ncurses_hide_panel — Remove panel from the stack, making it invisible
  51. ncurses_hline — Draw a horizontal line at current position using an attributed character and max. n characters long
  52. ncurses_inch — Get character and attribute at current position
  53. ncurses_init_color — Define a terminal color
  54. ncurses_init_pair — Define a color pair
  55. ncurses_init — Initialize ncurses
  56. ncurses_insch — Insert character moving rest of line including character at current position
  57. ncurses_insdelln — Insert lines before current line scrolling down (negative numbers delete and scroll up)
  58. ncurses_insertln — Insert a line, move rest of screen down
  59. ncurses_insstr — Insert string at current position, moving rest of line right
  60. ncurses_instr — Reads string from terminal screen
  61. ncurses_isendwin — Ncurses is in endwin mode, normal screen output may be performed
  62. ncurses_keyok — Enable or disable a keycode
  63. ncurses_keypad — Turns keypad on or off
  64. ncurses_killchar — Returns current line kill character
  65. ncurses_longname — Returns terminals description
  66. ncurses_meta — Enables/Disable 8-bit meta key information
  67. ncurses_mouse_trafo — Transforms coordinates
  68. ncurses_mouseinterval — Set timeout for mouse button clicks
  69. ncurses_mousemask — Sets mouse options
  70. ncurses_move_panel — Moves a panel so that its upper-left corner is at [startx, starty]
  71. ncurses_move — Move output position
  72. ncurses_mvaddch — Move current position and add character
  73. ncurses_mvaddchnstr — Move position and add attributed string with specified length
  74. ncurses_mvaddchstr — Move position and add attributed string
  75. ncurses_mvaddnstr — Move position and add string with specified length
  76. ncurses_mvaddstr — Move position and add string
  77. ncurses_mvcur — Move cursor immediately
  78. ncurses_mvdelch — Move position and delete character, shift rest of line left
  79. ncurses_mvgetch — Move position and get character at new position
  80. ncurses_mvhline — Set new position and draw a horizontal line using an attributed character and max. n characters long
  81. ncurses_mvinch — Move position and get attributed character at new position
  82. ncurses_mvvline — Set new position and draw a vertical line using an attributed character and max. n characters long
  83. ncurses_mvwaddstr — Add string at new position in window
  84. ncurses_napms — Sleep
  85. ncurses_new_panel — Create a new panel and associate it with window
  86. ncurses_newpad — Creates a new pad (window)
  87. ncurses_newwin — Create a new window
  88. ncurses_nl — Translate newline and carriage return / line feed
  89. ncurses_nocbreak — Switch terminal to cooked mode
  90. ncurses_noecho — Switch off keyboard input echo
  91. ncurses_nonl — Do not translate newline and carriage return / line feed
  92. ncurses_noqiflush — Do not flush on signal characters
  93. ncurses_noraw — Switch terminal out of raw mode
  94. ncurses_pair_content — Retrieves foreground and background colors of a color pair
  95. ncurses_panel_above — Returns the panel above panel
  96. ncurses_panel_below — Returns the panel below panel
  97. ncurses_panel_window — Returns the window associated with panel
  98. ncurses_pnoutrefresh — Copies a region from a pad into the virtual screen
  99. ncurses_prefresh — Copies a region from a pad into the virtual screen
  100. ncurses_putp — Apply padding information to the string and output it
  101. ncurses_qiflush — Flush on signal characters
  102. ncurses_raw — Switch terminal into raw mode
  103. ncurses_refresh — Refresh screen
  104. ncurses_replace_panel — Replaces the window associated with panel
  105. ncurses_reset_prog_mode — Resets the prog mode saved by def_prog_mode
  106. ncurses_reset_shell_mode — Resets the shell mode saved by def_shell_mode
  107. ncurses_resetty — Restores saved terminal state
  108. ncurses_savetty — Saves terminal state
  109. ncurses_scr_dump — Dump screen content to file
  110. ncurses_scr_init — Initialize screen from file dump
  111. ncurses_scr_restore — Restore screen from file dump
  112. ncurses_scr_set — Inherit screen from file dump
  113. ncurses_scrl — Scroll window content up or down without changing current position
  114. ncurses_show_panel — Places an invisible panel on top of the stack, making it visible
  115. ncurses_slk_attr — Returns current soft label key attribute
  116. ncurses_slk_attroff — Turn off the given attributes for soft function-key labels
  117. ncurses_slk_attron — Turn on the given attributes for soft function-key labels
  118. ncurses_slk_attrset — Set given attributes for soft function-key labels
  119. ncurses_slk_clear — Clears soft labels from screen
  120. ncurses_slk_color — Sets color for soft label keys
  121. ncurses_slk_init — Initializes soft label key functions
  122. ncurses_slk_noutrefresh — Copies soft label keys to virtual screen
  123. ncurses_slk_refresh — Copies soft label keys to screen
  124. ncurses_slk_restore — Restores soft label keys
  125. ncurses_slk_set — Sets function key labels
  126. ncurses_slk_touch — Forces output when ncurses_slk_noutrefresh is performed
  127. ncurses_standend — Stop using 'standout' attribute
  128. ncurses_standout — Start using 'standout' attribute
  129. ncurses_start_color — Initializes color functionality
  130. ncurses_termattrs — Returns a logical OR of all attribute flags supported by terminal
  131. ncurses_termname — Returns terminals (short)-name
  132. ncurses_timeout — Set timeout for special key sequences
  133. ncurses_top_panel — Moves a visible panel to the top of the stack
  134. ncurses_typeahead — Specify different filedescriptor for typeahead checking
  135. ncurses_ungetch — Put a character back into the input stream
  136. ncurses_ungetmouse — Pushes mouse event to queue
  137. ncurses_update_panels — Refreshes the virtual screen to reflect the relations between panels in the stack
  138. ncurses_use_default_colors — Assign terminal default colors to color id -1
  139. ncurses_use_env — Control use of environment information about terminal size
  140. ncurses_use_extended_names — Control use of extended names in terminfo descriptions
  141. ncurses_vidattr — Display the string on the terminal in the video attribute mode
  142. ncurses_vline — Draw a vertical line at current position using an attributed character and max. n characters long
  143. ncurses_waddch — Adds character at current position in a window and advance cursor
  144. ncurses_waddstr — Outputs text at current postion in window
  145. ncurses_wattroff — Turns off attributes for a window
  146. ncurses_wattron — Turns on attributes for a window
  147. ncurses_wattrset — Set the attributes for a window
  148. ncurses_wborder — Draws a border around the window using attributed characters
  149. ncurses_wclear — Clears window
  150. ncurses_wcolor_set — Sets windows color pairings
  151. ncurses_werase — Erase window contents
  152. ncurses_wgetch — Reads a character from keyboard (window)
  153. ncurses_whline — Draws a horizontal line in a window at current position using an attributed character and max. n characters long
  154. ncurses_wmouse_trafo — Transforms window/stdscr coordinates
  155. ncurses_wmove — Moves windows output position
  156. ncurses_wnoutrefresh — Copies window to virtual screen
  157. ncurses_wrefresh — Refresh window on terminal screen
  158. ncurses_wstandend — End standout mode for a window
  159. ncurses_wstandout — Enter standout mode for a window
  160. ncurses_wvline — Draws a vertical line in a window at current position using an attributed character and max. n characters long

----------------------------

The readline functions implement an interface to the GNU Readline library. These are functions that provide editable command lines. An example being the way Bash allows you to use the arrow keys to insert characters or scroll through command history. Because of the interactive nature of this library, it will be of little use for writing Web applications, but may be useful when writing scripts used from a command line.

As of PHP 7.1.0 this extension is supported on Windows.

  1. readline_add_history — Adds a line to the history
  2. readline_callback_handler_install — Initializes the readline callback interface and terminal, prints the prompt and returns immediately
  3. readline_callback_handler_remove — Removes a previously installed callback handler and restores terminal settings
  4. readline_callback_read_char — Reads a character and informs the readline callback interface when a line is received
  5. readline_clear_history — Clears the history
  6. readline_completion_function — Registers a completion function
  7. readline_info — Gets/sets various internal readline variables
  8. readline_list_history — Lists the history
  9. readline_on_new_line — Inform readline that the cursor has moved to a new line
  10. readline_read_history — Reads the history
  11. readline_redisplay — Redraws the display
  12. readline_write_history — Writes the history
  13. readline — Reads a line

------------------------------

Compression and Archive Extensions

The bzip2 functions are used to transparently read and write bzip2 (.bz2) compressed files.

Bzip2 Functions

LZF is a very fast compression algorithm, ideal for saving space with only slight speed cost. It can be optimized for speed or space at the time of compilation. This extension is using » liblzf library by Marc Lehmann for its operations.

The phar extension provides a way to put entire PHP applications into a single file called a "phar" (PHP Archive) for easy distribution and installation. In addition to providing this service, the phar extension also provides a file-format abstraction method for creating and manipulating tar and zip files through the PharData class, much as PDO provides a unified interface for accessing different databases. Unlike PDO, which cannot convert between different databases, Phar also can convert between tar, zip and phar file formats with a single line of code. see Phar::convertToExecutable() for one example.

What is phar? Phar archives are best characterized as a convenient way to group several files into a single file. As such, a phar archive provides a way to distribute a complete PHP application in a single file and run it from that file without the need to extract it to disk. Additionally, phar archives can be executed by PHP as easily as any other file, both on the commandline and from a web server. Phar is kind of like a thumb drive for PHP applications.

Phar implements this functionality through a Stream Wrapper. Normally, to use an external file within a PHP script, you would use include

Example #1 Using an external file

<?php
 include '/path/to/external/file.php';
 ?>

PHP can be thought of as actually translating /path/to/external/file.php into a stream wrapper as file:///path/to/external/file.php, and under the hood it does in fact use the plain file stream wrapper stream functions to access all local files.

To use a file named file.php contained with a phar archive /path/to/myphar.phar, the syntax is very similar to the file:// syntax above.

Example #2 Using a file within a phar archive

<?php
 include 'phar:///path/to/myphar.phar/file.php';
 ?>

In fact, one can treat a phar archive exactly as if it were an external disk, using any of fopen()-related functions, opendir() and mkdir()-related functions to read, change, or create new files and directories within the phar archive. This allows complete PHP applications to be distributed in a single file and run directly from that file.

The most common usage for a phar archive is to distribute a complete application in a single file. For instance, the PEAR Installer that is bundled with PHP versions is distributed as a phar archive. To use a phar archive distributed in this way, the archive can be executed on the command-line or via a web server.

Phar archives can be distributed as tar archives, zip archives, or as the custom phar file format designed specifically for the phar extension. Each file format has advantages and disadvantages. The tar and zip file formats can be read or extracted by any third-party tool that can read the format, but require the phar extension in order to run with PHP. The phar file format is customized and unique to the phar extension, and can only be created by the phar extension or the PEAR package » PHP_Archive, but has the advantage that applications created in this format will run even if the phar extension is not enabled.

In other words, even with the phar extension disabled, one can execute or include a phar-based archive. Accessing individual files within a phar archive is only possible with the phar extension unless the phar archive was created by PHP_Archive.

The phar extension is also capable of converting a phar archive from tar to zip or to phar file format in a single command:

Example #3 Converting a phar archive from phar to tar file format

<?php
 $phar = new Phar('myphar.phar');
 $pgz = $phar->convertToExecutable(Phar::TAR, Phar::GZ); // makes myphar.phar.tar.gz
 ?>

Phar can compress individual files or an entire archive using gzip compression or bzip2 compression, and can verify archive integrity automatically through the use of MD5, SHA-1, SHA-256 or SHA-512 signatures.

Lastly, the Phar extension is security-conscious, and disables write access to executable phar archives by default, and requires system-level disabling of the phar.readonly php.ini setting in order to create or modify phar archives. Normal tar and zip archives without an executable stub can always be created or modified using the PharData class.

If you are creating applications for distribution, you will want to read How to create Phar Archives. If you want more information on the differences between the three file formats that phar supports, you should read Phar, Tar and Zip.

If you are using phar applications, there are helpful tips in How to use Phar Archives

The word phar is a portmanteau of PHP and Archive and is based loosely on the jar (Java Archive) familiar to Java developers.

The implementation for Phar archives is based on the PEAR package » PHP_Archive, and the implementation details are similar, although the Phar extension is much more powerful. In addition, the Phar extension allows most PHP applications to be run unmodified while PHP_Archive-based phar archives often require extensive modification in order to work.

Creating Phar Archives

A great place to start is by reading about Phar::buildFromIterator(), and the specifics of the file format choices available for archives. A healthy understanding of what a stub is and does is crucial to phar archive creation, and so Phar::setStub() and Phar::createDefaultStub() are good places to start as well. If you are distributing a web-based application, it is crucial to know about Phar::webPhar() and related method Phar::mungServer(). Any application that accesses its own files should also consider using Phar::interceptFileFuncs().

Rar:

Rar is a powerful and effective archiver created by Eugene Roshal. This extension gives you possibility to read Rar archives but doesn't support writing Rar archives, because this is not supported by the UnRar library and is directly prohibited by its license.

More information about Rar and UnRar can be found at » http://www.rarlabs.com/.

Zip:

This extension enables you to transparently read or write ZIP compressed archives and the files inside them.

Zlib:

This module enables you to transparently read and write gzip (.gz) compressed files, through versions of most of the filesystem functions which work with gzip-compressed files (and uncompressed files, too, but not with sockets).

----------------------------------------------------------

Cryptography Extensions

1. CSPRNG

The » cryptographically secure pseudo-random number generator (CSPRNG) API provides an easy and reliable way to generate crypto-strong random integers and bytes for use within cryptographic contexts.

This exists as of PHP 7.0.0 but there is also a » userland implementation for PHP >= 5.2.0.

This extension has no constants defined.

2. Hash — HASH Message Digest Framework (PHP 7 >= 7.2.0, PHP 8)

Message Digest (hash) engine. Allows direct or incremental processing of arbitrary length messages using a variety of hashing algorithms.

HashContext { __contruct() } //


3. Mcrypt (Note: This feature was DEPRECATED in PHP 7.1.0, and REMOVED in PHP 7.2.0.)

Alternatives to this feature include:


This is an interface to the mcrypt library, which supports a wide variety of block algorithms such as DES, TripleDES, Blowfish (default), 3-WAY, SAFER-SK64, SAFER-SK128, TWOFISH, TEA, RC2 and GOST in CBC, OFB, CFB and ECB cipher modes. Additionally, it supports RC6 and IDEA which are considered "non-free". CFB/OFB are 8bit by default.

4. Mhash (Note: This extension is obsoleted by Hash)

These functions are intended to work with » mhash. Mhash can be used to create checksums, message digests, message authentication codes, and more.

This is an interface to the mhash library. Mhash supports a wide variety of hash algorithms such as MD5, SHA1, GOST, and many others. For a complete list of supported hashes, refer to the constants page. The general rule is that you can access the hash algorithm from PHP with MHASH_hashname. For example, to access TIGER you use the PHP constant MHASH_TIGER.

As of PHP 7.0.0 the Mhash extension has been fully integrated into the Hash extension. Therefore, it is no longer possible to detect Mhash support with extension_loaded(); use function_exists() instead. Furthermore, Mhash is no longer reported by get_loaded_extensions() and related features.

Predefined Constants 5. OpenSSL

This extension binds functions of » OpenSSL library for symmetric and asymmetric encryption and decryption, PBKDF2, PKCS7, PKCS12, X509 and other crypto operations. In addition to that it provides implementation of TLS streams.

OpenSSL offers many features that this module currently doesn't support. Some of these may be added in the future.

The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.

6. Password Hashing


The password hashing API provides an easy to use wrapper around  crypt() and some other password hashing algorithms, to make it easy to create and manage passwords in a secure manner.

This extension is available since PHP 5.5.0 but there is also an » userland implementation for PHP >= 5.3.7.

The constants below are always available as part of the PHP core.

PASSWORD_BCRYPT (string)

PASSWORD_BCRYPT is used to create new password hashes using the CRYPT_BLOWFISH algorithm.

This will always result in a hash using the "$2y$" crypt format, which is always 60 characters wide.

Supported Options:

PASSWORD_ARGON2I (string)

PASSWORD_ARGON2I is used to create new password hashes using the Argon2i algorithm.

Supported Options:

Available as of PHP 7.2.0.

PASSWORD_ARGON2ID (string)

PASSWORD_ARGON2ID is used to create new password hashes using the Argon2id algorithm. It supports the same options as PASSWORD_ARGON2I.

Available as of PHP 7.3.0.

PASSWORD_ARGON2_DEFAULT_MEMORY_COST (int)

Default amount of memory in bytes that Argon2lib will use while trying to compute a hash.

Available as of PHP 7.2.0.

PASSWORD_ARGON2_DEFAULT_TIME_COST (int)

Default amount of time that Argon2lib will spend trying to compute a hash.

Available as of PHP 7.2.0.

PASSWORD_ARGON2_DEFAULT_THREADS (int)

Default number of threads that Argon2lib will use.

Available as of PHP 7.2.0.

PASSWORD_DEFAULT (mixed)

The default algorithm to use for hashing if no algorithm is provided. This may change in newer PHP releases when newer, stronger hashing algorithms are supported.

It is worth noting that over time this constant can (and likely will) change. Therefore you should be aware that the length of the resulting hash can change. Therefore, if you use PASSWORD_DEFAULT you should store the resulting hash in a way that can store more than 60 characters (255 is the recommended width).

Values for this constant:

7. Sodium

SODIUM_LIBRARY_VERSION (string)
SODIUM_LIBRARY_MAJOR_VERSION (int)
SODIUM_LIBRARY_MINOR_VERSION (int)
SODIUM_CRYPTO_AEAD_AES256GCM_KEYBYTES (int)
SODIUM_CRYPTO_AEAD_AES256GCM_NSECBYTES (int)
SODIUM_CRYPTO_AEAD_AES256GCM_NPUBBYTES (int)
SODIUM_CRYPTO_AEAD_AES256GCM_ABYTES (int)
SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_KEYBYTES (int)
SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_NSECBYTES (int)
SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_NPUBBYTES (int)
SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_ABYTES (int)
SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_KEYBYTES (int)
SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_NSECBYTES (int)
SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_NPUBBYTES (int)
SODIUM_CRYPTO_AEAD_CHACHA20POLY1305_IETF_ABYTES (int)
SODIUM_CRYPTO_AUTH_BYTES (int)
SODIUM_CRYPTO_AUTH_KEYBYTES (int)
SODIUM_CRYPTO_BOX_SEALBYTES (int)
SODIUM_CRYPTO_BOX_SECRETKEYBYTES (int)
SODIUM_CRYPTO_BOX_PUBLICKEYBYTES (int)
SODIUM_CRYPTO_BOX_KEYPAIRBYTES (int)
SODIUM_CRYPTO_BOX_MACBYTES (int)
SODIUM_CRYPTO_BOX_NONCEBYTES (int)
SODIUM_CRYPTO_BOX_SEEDBYTES (int)
SODIUM_CRYPTO_KDF_BYTES_MIN (int)
SODIUM_CRYPTO_KDF_BYTES_MAX (int)
SODIUM_CRYPTO_KDF_CONTEXTBYTES (int)
SODIUM_CRYPTO_KDF_KEYBYTES (int)
SODIUM_CRYPTO_KX_SEEDBYTES (int)
SODIUM_CRYPTO_KX_SESSIONKEYBYTES (int)
SODIUM_CRYPTO_KX_PUBLICKEYBYTES (int)
SODIUM_CRYPTO_KX_SECRETKEYBYTES (int)
SODIUM_CRYPTO_KX_KEYPAIRBYTES (int)
SODIUM_CRYPTO_GENERICHASH_BYTES (int)
SODIUM_CRYPTO_GENERICHASH_BYTES_MIN (int)
SODIUM_CRYPTO_GENERICHASH_BYTES_MAX (int)
SODIUM_CRYPTO_GENERICHASH_KEYBYTES (int)
SODIUM_CRYPTO_GENERICHASH_KEYBYTES_MIN (int)
SODIUM_CRYPTO_GENERICHASH_KEYBYTES_MAX (int)
SODIUM_CRYPTO_PWHASH_ALG_ARGON2I13 (int)
SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13 (int)
SODIUM_CRYPTO_PWHASH_ALG_DEFAULT (int)
SODIUM_CRYPTO_PWHASH_SALTBYTES (int)
SODIUM_CRYPTO_PWHASH_STRPREFIX (string)
SODIUM_CRYPTO_PWHASH_OPSLIMIT_INTERACTIVE (int)
SODIUM_CRYPTO_PWHASH_MEMLIMIT_INTERACTIVE (int)
SODIUM_CRYPTO_PWHASH_OPSLIMIT_MODERATE (int)
SODIUM_CRYPTO_PWHASH_MEMLIMIT_MODERATE (int)
SODIUM_CRYPTO_PWHASH_OPSLIMIT_SENSITIVE (int)
SODIUM_CRYPTO_PWHASH_MEMLIMIT_SENSITIVE (int)
SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_SALTBYTES (int)
SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_STRPREFIX (string)
SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_INTERACTIVE (int)
SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_INTERACTIVE (int)
SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_SENSITIVE (int)
SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_SENSITIVE (int)
SODIUM_CRYPTO_SCALARMULT_BYTES (int)
SODIUM_CRYPTO_SCALARMULT_SCALARBYTES (int)
SODIUM_CRYPTO_SHORTHASH_BYTES (int)
SODIUM_CRYPTO_SHORTHASH_KEYBYTES (int)
SODIUM_CRYPTO_SECRETBOX_KEYBYTES (int)
SODIUM_CRYPTO_SECRETBOX_MACBYTES (int)
SODIUM_CRYPTO_SECRETBOX_NONCEBYTES (int)
SODIUM_CRYPTO_SIGN_BYTES (int)
SODIUM_CRYPTO_SIGN_SEEDBYTES (int)
SODIUM_CRYPTO_SIGN_PUBLICKEYBYTES (int)
SODIUM_CRYPTO_SIGN_SECRETKEYBYTES (int)
SODIUM_CRYPTO_SIGN_KEYPAIRBYTES (int)
SODIUM_CRYPTO_STREAM_NONCEBYTES (int)
SODIUM_CRYPTO_STREAM_KEYBYTES (int)

---------------------------------------------------------------------------------------------

Database Extensions

Abstraction Layers

Vendor Specific Database Extensions

Abstraction Layers

  1. 1. DBA — Database (dbm-style) Abstraction Layer
    These functions build the foundation for accessing Berkeley DB style databases.

  2. 2. ODBC — ODBC (Unified)

    In addition to normal ODBC support, the Unified ODBC functions in PHP allow you to access several databases that have borrowed the semantics of the ODBC API to implement their own API. Instead of maintaining multiple database drivers that were all nearly identical, these drivers have been unified into a single set of ODBC functions.


    ODBC_TYPE (int)
    ODBC_BINMODE_PASSTHRU (int)
    ODBC_BINMODE_RETURN (int)
    ODBC_BINMODE_CONVERT (int)
    SQL_ODBC_CURSORS (int)
    SQL_CUR_USE_DRIVER (int)
    SQL_CUR_USE_IF_NEEDED (int)
    SQL_CUR_USE_ODBC (int)
    SQL_CONCURRENCY (int)
    SQL_CONCUR_READ_ONLY (int)
    SQL_CONCUR_LOCK (int)
    SQL_CONCUR_ROWVER (int)
    SQL_CONCUR_VALUES (int)
    SQL_CURSOR_TYPE (int)
    SQL_CURSOR_FORWARD_ONLY (int)
    SQL_CURSOR_KEYSET_DRIVEN (int)
    SQL_CURSOR_DYNAMIC (int)
    SQL_CURSOR_STATIC (int)
    SQL_KEYSET_SIZE (int)
    SQL_CHAR (int)
    SQL_VARCHAR (int)
    SQL_LONGVARCHAR (int)
    SQL_DECIMAL (int)
    SQL_NUMERIC (int)
    SQL_BIT (int)
    SQL_TINYINT (int)
    SQL_SMALLINT (int)
    SQL_INTEGER (int)
    SQL_BIGINT (int)
    SQL_REAL (int)
    SQL_FLOAT (int)
    SQL_DOUBLE (int)
    SQL_BINARY (int)
    SQL_VARBINARY (int)
    SQL_LONGVARBINARY (int)
    SQL_DATE (int)
    SQL_TIME (int)
    SQL_TIMESTAMP (int)
    SQL_TYPE_DATE (int)
    SQL_TYPE_TIME (int)
    SQL_TYPE_TIMESTAMP (int)
    SQL_BEST_ROWID (int)
    SQL_ROWVER (int)
    SQL_SCOPE_CURROW (int)
    SQL_SCOPE_TRANSACTION (int)
    SQL_SCOPE_SESSION (int)
    SQL_NO_NULLS (int)
    SQL_NULLABLE (int)
    SQL_INDEX_UNIQUE (int)
    SQL_INDEX_ALL (int)
    SQL_ENSURE (int)
    SQL_QUICK (int)
  3. 3. PDO — PHP Data Objects

    The PHP Data Objects (PDO) extension defines a lightweight, consistent interface for accessing databases in PHP. Each database driver that implements the PDO interface can expose database-specific features as regular extension functions. Note that you cannot perform any database functions using the PDO extension by itself; you must use a database-specific PDO driver to access a database server.

    PDO provides a data-access abstraction layer, which means that, regardless of which database you're using, you use the same functions to issue queries and fetch data. PDO does not provide a database abstraction; it doesn't rewrite SQL or emulate missing features. You should use a full-blown abstraction layer if you need that facility.

    PDO ships with PHP 5.1, and is available as a PECL extension for PHP 5.0; PDO requires the new OO features in the core of PHP 5, and so will not run with earlier versions of PHP.

    PDO Contstants

    PDO::PARAM_BOOL (int)
    Represents a boolean data type.
    PDO::PARAM_NULL (int)
    Represents the SQL NULL data type.
    PDO::PARAM_INT (int)
    Represents the SQL INTEGER data type.
    PDO::PARAM_STR (int)
    Represents the SQL CHAR, VARCHAR, or other string data type.
    PDO::PARAM_STR_NATL (int)
    Flag to denote a string uses the national character set. Available since PHP 7.2.0
    PDO::PARAM_STR_CHAR (int)
    Flag to denote a string uses the regular character set. Available since PHP 7.2.0
    PDO::PARAM_LOB (int)
    Represents the SQL large object data type.
    PDO::PARAM_STMT (int)
    Represents a recordset type. Not currently supported by any drivers.
    PDO::PARAM_INPUT_OUTPUT (int)
    Specifies that the parameter is an INOUT parameter for a stored procedure. You must bitwise-OR this value with an explicit PDO::PARAM_* data type.
    PDO::FETCH_LAZY (int)
    Specifies that the fetch method shall return each row as an object with variable names that correspond to the column names returned in the result set. PDO::FETCH_LAZY creates the object variable names as they are accessed. Not valid inside PDOStatement::fetchAll().
    PDO::FETCH_ASSOC (int)
    Specifies that the fetch method shall return each row as an array indexed by column name as returned in the corresponding result set. If the result set contains multiple columns with the same name, PDO::FETCH_ASSOC returns only a single value per column name.
    PDO::FETCH_NAMED (int)
    Specifies that the fetch method shall return each row as an array indexed by column name as returned in the corresponding result set. If the result set contains multiple columns with the same name, PDO::FETCH_NAMED returns an array of values per column name.
    PDO::FETCH_NUM (int)
    Specifies that the fetch method shall return each row as an array indexed by column number as returned in the corresponding result set, starting at column 0.
    PDO::FETCH_BOTH (int)
    Specifies that the fetch method shall return each row as an array indexed by both column name and number as returned in the corresponding result set, starting at column 0.
    PDO::FETCH_OBJ (int)
    Specifies that the fetch method shall return each row as an object with property names that correspond to the column names returned in the result set.
    PDO::FETCH_BOUND (int)
    Specifies that the fetch method shall return TRUE and assign the values of the columns in the result set to the PHP variables to which they were bound with the PDOStatement::bindParam() or PDOStatement::bindColumn() methods.
    PDO::FETCH_COLUMN (int)
    Specifies that the fetch method shall return only a single requested column from the next row in the result set.
    PDO::FETCH_CLASS (int)
    Specifies that the fetch method shall return a new instance of the requested class, mapping the columns to named properties in the class.

    Note: The magic __set() method is called if the property doesn't exist in the requested class

    PDO::FETCH_INTO (int)
    Specifies that the fetch method shall update an existing instance of the requested class, mapping the columns to named properties in the class.
    PDO::FETCH_FUNC (int)
    Allows completely customize the way data is treated on the fly (only valid inside PDOStatement::fetchAll()).
    PDO::FETCH_GROUP (int)
    Group return by values. Usually combined with PDO::FETCH_COLUMN or PDO::FETCH_KEY_PAIR.
    PDO::FETCH_UNIQUE (int)
    Fetch only the unique values.
    PDO::FETCH_KEY_PAIR (int)
    Fetch a two-column result into an array where the first column is a key and the second column is the value. Available since PHP 5.2.3.
    PDO::FETCH_CLASSTYPE (int)
    Determine the class name from the value of first column.
    PDO::FETCH_SERIALIZE (int)
    As PDO::FETCH_INTO but object is provided as a serialized string. Available since PHP 5.1.0. Since PHP 5.3.0 the class constructor is never called if this flag is set.
    PDO::FETCH_PROPS_LATE (int)
    Call the constructor before setting properties. Available since PHP 5.2.0.
    PDO::ATTR_AUTOCOMMIT (int)
    If this value is false, PDO attempts to disable autocommit so that the connection begins a transaction.
    PDO::ATTR_PREFETCH (int)
    Setting the prefetch size allows you to balance speed against memory usage for your application. Not all database/driver combinations support setting of the prefetch size. A larger prefetch size results in increased performance at the cost of higher memory usage.
    PDO::ATTR_TIMEOUT (int)
    Sets the timeout value in seconds for communications with the database.
    PDO::ATTR_ERRMODE (int)
    See the Errors and error handling section for more information about this attribute.
    PDO::ATTR_SERVER_VERSION (int)
    This is a read only attribute; it will return information about the version of the database server to which PDO is connected.
    PDO::ATTR_CLIENT_VERSION (int)
    This is a read only attribute; it will return information about the version of the client libraries that the PDO driver is using.
    PDO::ATTR_SERVER_INFO (int)
    This is a read only attribute; it will return some meta information about the database server to which PDO is connected.
    PDO::ATTR_CONNECTION_STATUS (int)
    PDO::ATTR_CASE (int)
    Force column names to a specific case specified by the PDO::CASE_* constants.
    PDO::ATTR_CURSOR_NAME (int)
    Get or set the name to use for a cursor. Most useful when using scrollable cursors and positioned updates.
    PDO::ATTR_CURSOR (int)
    Selects the cursor type. PDO currently supports either PDO::CURSOR_FWDONLY and PDO::CURSOR_SCROLL. Stick with PDO::CURSOR_FWDONLY unless you know that you need a scrollable cursor.
    PDO::ATTR_DRIVER_NAME (string)
    Returns the name of the driver.

    Example #1 using PDO::ATTR_DRIVER_NAME

    <?php
    if ($db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'mysql') {
      echo "Running on mysql; doing something mysql specific here\n";
    }
    ?>
    PDO::ATTR_ORACLE_NULLS (int)
    Convert empty strings to SQL NULL values on data fetches.
    PDO::ATTR_PERSISTENT (mixed)
    Request a persistent connection, rather than creating a new connection. See Connections and Connection management for more information on this attribute.
    PDO::ATTR_STATEMENT_CLASS (int)
    Sets the class name of which statements are returned as.
    PDO::ATTR_FETCH_CATALOG_NAMES (int)
    Prepend the containing catalog name to each column name returned in the result set. The catalog name and column name are separated by a decimal (.) character. Support of this attribute is at the driver level; it may not be supported by your driver.
    PDO::ATTR_FETCH_TABLE_NAMES (int)
    Prepend the containing table name to each column name returned in the result set. The table name and column name are separated by a decimal (.) character. Support of this attribute is at the driver level; it may not be supported by your driver.
    PDO::ATTR_STRINGIFY_FETCHES (int)
    Forces all values fetched to be treated as strings.
    PDO::ATTR_MAX_COLUMN_LEN (int)
    Sets the maximum column name length.
    PDO::ATTR_DEFAULT_FETCH_MODE (int)
    Available since PHP 5.2.0
    PDO::ATTR_EMULATE_PREPARES (int)
    Available since PHP 5.1.3.
    PDO::ATTR_DEFAULT_STR_PARAM (int)
    Sets the default string parameter type, this can be one of PDO::PARAM_STR_NATL and PDO::PARAM_STR_CHAR. Available since PHP 7.2.0.
    PDO::ERRMODE_SILENT (int)
    Do not raise an error or exception if an error occurs. The developer is expected to explicitly check for errors. This is the default mode. See Errors and error handling for more information about this attribute.
    PDO::ERRMODE_WARNING (int)
    Issue a PHP E_WARNING message if an error occurs. See Errors and error handling for more information about this attribute.
    PDO::ERRMODE_EXCEPTION (int)
    Throw a PDOException if an error occurs. See Errors and error handling for more information about this attribute.
    PDO::CASE_NATURAL (int)
    Leave column names as returned by the database driver.
    PDO::CASE_LOWER (int)
    Force column names to lower case.
    PDO::CASE_UPPER (int)
    Force column names to upper case.
    PDO::NULL_NATURAL (int)
    PDO::NULL_EMPTY_STRING (int)
    PDO::NULL_TO_STRING (int)
    PDO::FETCH_ORI_NEXT (int)
    Fetch the next row in the result set. Valid only for scrollable cursors.
    PDO::FETCH_ORI_PRIOR (int)
    Fetch the previous row in the result set. Valid only for scrollable cursors.
    PDO::FETCH_ORI_FIRST (int)
    Fetch the first row in the result set. Valid only for scrollable cursors.
    PDO::FETCH_ORI_LAST (int)
    Fetch the last row in the result set. Valid only for scrollable cursors.
    PDO::FETCH_ORI_ABS (int)
    Fetch the requested row by row number from the result set. Valid only for scrollable cursors.
    PDO::FETCH_ORI_REL (int)
    Fetch the requested row by relative position from the current position of the cursor in the result set. Valid only for scrollable cursors.
    PDO::CURSOR_FWDONLY (int)
    Create a PDOStatement object with a forward-only cursor. This is the default cursor choice, as it is the fastest and most common data access pattern in PHP.
    PDO::CURSOR_SCROLL (int)
    Create a PDOStatement object with a scrollable cursor. Pass the PDO::FETCH_ORI_* constants to control the rows fetched from the result set.
    PDO::ERR_NONE (string)
    Corresponds to SQLSTATE '00000', meaning that the SQL statement was successfully issued with no errors or warnings. This constant is for your convenience when checking PDO::errorCode() or PDOStatement::errorCode() to determine if an error occurred. You will usually know if this is the case by examining the return code from the method that raised the error condition anyway.
    PDO::PARAM_EVT_ALLOC (int)
    Allocation event
    PDO::PARAM_EVT_FREE (int)
    Deallocation event
    PDO::PARAM_EVT_EXEC_PRE (int)
    Event triggered prior to execution of a prepared statement.
    PDO::PARAM_EVT_EXEC_POST (int)
    Event triggered subsequent to execution of a prepared statement.
    PDO::PARAM_EVT_FETCH_PRE (int)
    Event triggered prior to fetching a result from a resultset.
    PDO::PARAM_EVT_FETCH_POST (int)
    Event triggered subsequent to fetching a result from a resultset.
    PDO::PARAM_EVT_NORMALIZE (int)
    Event triggered during bound parameter registration allowing the driver to normalize the parameter name.
    PDO::SQLITE_DETERMINISTIC (int)
    Specifies that a function created with PDO::sqliteCreateFunction() is deterministic, i.e. it always returns the same result given the same inputs within a single SQL statement. (Available as of PHP 7.1.4.)
    <?php
    try {
        $dbh = new PDO('mysql:host=localhost;dbname=test', $user, $pass, array(
        PDO::ATTR_PERSISTENT => true
    ));
        foreach($dbh->query('SELECT * from FOO') as $row) {
            print_r($row);
        }
        $dbh = null; // Close the connection
    } catch (PDOException $e) {
        print "Error!: " . $e->getMessage() . "<br/>";
        die();
    }
    ?>

    Transactions: 4 major features: Atomicity, Consistency, Isolation and Durability (ACID)

    Transactions and auto-commit

    <?php
    try {
      $dbh = new PDO('odbc:SAMPLE', 'db2inst1', 'ibmdb2', 
          array(PDO::ATTR_PERSISTENT => true));
      echo "Connected\n";
    } catch (Exception $e) {
      die("Unable to connect: " . $e->getMessage());
    }

    try {  
      $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

      $dbh->beginTransaction();
      $dbh->exec("insert into staff (id, first, last) values (23, 'Joe', 'Bloggs')");
      $dbh->exec("insert into salarychange (id, amount, changedate) 
          values (23, 50000, NOW())");
      $dbh->commit();
      
    } catch (Exception $e) {
      $dbh->rollBack();
      echo "Failed: " . $e->getMessage();
    }
    ?>

    Prepared statements and stored procedures

    <?php
    $stmt = $dbh->prepare("INSERT INTO REGISTRY (name, value) VALUES (:name, :value)");
    $stmt->bindParam(':name', $name);
    $stmt->bindParam(':value', $value);

    // insert one row
    $name = 'one';
    $value = 1;
    $stmt->execute();

    // insert another row with different values
    $name = 'two';
    $value = 2;
    $stmt->execute();
    ?>

    Errors and error handling

    PDO::ERRMODE_SILENT

    PDO::ERRMODE_WARNING

    PDO::ERRMODE_EXCEPTION


    <?php
    $dsn = 'mysql:dbname=testdb;host=127.0.0.1';
    $user = 'dbuser';
    $password = 'dbpass';

    try {
        $dbh = new PDO($dsn, $user, $password);
        $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    } catch (PDOException $e) {
        echo 'Connection failed: ' . $e->getMessage();
    }

    ?>

    PDO {
    public __construct ( string $dsn , string $username = ? , string $passwd = ? , array $options = ? )
    public beginTransaction ( ) : bool
    public commit ( ) : bool
    public errorCode ( ) : string
    public errorInfo ( ) : array
    public exec ( string $statement ) : int
    public getAttribute ( int $attribute ) : mixed
    public static getAvailableDrivers ( ) : array
    public inTransaction ( ) : bool
    public lastInsertId ( string $name = null ) : string
    public prepare ( string $statement , array $driver_options = array() ) : PDOStatement
    public query ( string $statement ) : PDOStatement
    public quote ( string $string , int $parameter_type = PDO::PARAM_STR ) : string
    public rollBack ( ) : bool
    public setAttribute ( int $attribute , mixed $value ) : bool
    }

    ---------------------------

    The PDOStatement class

    Represents a prepared statement and, after the statement is executed, an associated result set.

    --------------------------------------------------------------------------------

    The PDOException class

    Represents an error raised by PDO. You should not throw a PDOException from your own code. See Exceptions for more information about Exceptions in PHP.


    PDOException extends RuntimeException {
    /* Properties */
    public array $errorInfo ;
    protected string $code ;
    /* Inherited properties */
    protected string $message ;
    protected int $code ;
    protected string $file ;
    protected int $line ;
    /* Inherited methods */
    final public Exception::getMessage ( ) : string
    final publicException::getPrevious ( ) : Throwable|null
    final public Exception::getCode ( ) : mixed
    final public Exception::getFile ( ) : string
    final public Exception::getLine ( ) : int
    final public Exception::getTrace ( ) : array
    final public Exception::getTraceAsString ( ) : string
    public Exception::__toString ( ) : string
    final private Exception::__clone ( ) : void
    }
    errorInfo

    Corresponds to PDO::errorInfo() or PDOStatement::errorInfo()

    code

    SQLSTATE error code. Use Exception::getCode() to access it.

    ----------------------------------------------------------------------------

    PDO Drivers