https://www.php.net/manual/en/refs.compression.php
Affecting PHP's Behaviour
APCu Functions
- apcu_add — Cache a new variable in the data store
- apcu_cache_info — Retrieves cached information from APCu's data store
- apcu_cas — Updates an old value with a new value
- apcu_clear_cache — Clears the APCu cache
- apcu_dec — Decrease a stored number
- apcu_delete — Removes a stored variable from the cache
- apcu_enabled — Whether APCu is usable in the current environment
- apcu_entry — Atomically fetch or generate a cache entry
- apcu_exists — Checks if entry exists
- apcu_fetch — Fetch a stored variable from the cache
- apcu_inc — Increase a stored number
- apcu_key_info — Get detailed information about the cache key
- apcu_sma_info — Retrieves APCu Shared Memory Allocation information
- apcu_store — Cache a variable in the data store
APCUIterator — The APCUIterator class
- APCUIterator::__construct — Constructs an APCUIterator iterator object
- APCUIterator::current — Get current item
- APCUIterator::getTotalCount — Get total count
- APCUIterator::getTotalHits — Get total cache hits
- APCUIterator::getTotalSize — Get total cache size
- APCUIterator::key — Get iterator key
- APCUIterator::next — Move pointer to next item
- APCUIterator::rewind — Rewinds iterator
- APCUIterator::valid — Checks if current position is valid
Blenc Functions
- 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.
- Componere\Abstract\Definition — The Componere\Abstract\Definition class
- Componere\Abstract\Definition::addInterface — Add Interface
- Componere\Abstract\Definition::addMethod — Add Method
- Componere\Abstract\Definition::addTrait — Add Trait
- Componere\Abstract\Definition::getReflector — Reflection
- Componere\Definition — The Componere\Definition class
- Componere\Definition::__construct — Definition Construction
- Componere\Definition::addConstant — Add Constant
- Componere\Definition::addProperty — Add Property
- Componere\Definition::register — Registration
- Componere\Definition::isRegistered — State Detection
- Componere\Definition::getClosure — Get Closure
- Componere\Definition::getClosures — Get Closures
- Componere\Patch — The Componere\Patch class
- Componere\Patch::__construct — Patch Construction
- Componere\Patch::apply — Application
- Componere\Patch::revert — Reversal
- Componere\Patch::isApplied — State Detection
- Componere\Patch::derive — Patch Derivation
- Componere\Patch::getClosure — Get Closure
- Componere\Patch::getClosures — Get Closures
- Componere\Method — The Componere\Method class
- Componere\Method::__construct — Method Construction
- Componere\Method::setPrivate — Accessibility Modification
- Componere\Method::setProtected — Accessibility Modification
- Componere\Method::setStatic — Accessibility Modification
- Componere\Method::getReflector — Reflection
- Componere\Value — The Componere\Value class
- Componere\Value::__construct — Value Construction
- Componere\Value::setPrivate — Accessibility Modification
- Componere\Value::setProtected — Accessibility Modification
- Componere\Value::setStatic — Accessibility Modification
- Componere\Value::isPrivate — Accessibility Detection
- Componere\Value::isProtected — Accessibility Detection
- Componere\Value::isStatic — Accessibility Detection
- Componere\Value::hasDefault — Value Interaction
- Componere Functions
- Componere\cast — Casting
- Componere\cast_by_ref — Casting
---------------------------------
Error Handling Functions
- debug_backtrace — Generates a backtrace
- debug_print_backtrace — Prints a backtrace
- error_clear_last — Clear the most recent error
- error_get_last — Get the last occurred error
- error_log — Send an error message to the defined error handling routines
- error_reporting — Sets which PHP errors are reported
- restore_error_handler — Restores the previous error handler function
- restore_exception_handler — Restores the previously defined exception handler function
- set_error_handler — Sets a user-defined error handler function
- set_exception_handler — Sets a user-defined exception handler function
- trigger_error — Generates a user-level error/warning/notice message
- user_error — Alias of trigger_error
--------------------------------
FFI — Main interface to C code and data
- FFI::addr — Creates an unmanaged pointer to C data
- FFI::alignof — Gets the alignment
- FFI::arrayType — Dynamically constructs a new C array type
- FFI::cast — Performs a C type cast
- FFI::cdef — Creates a new FFI object
- FFI::free — Releases an unmanaged data structure
- FFI::isNull — Checks whether a FFI\CData is a null pointer
- FFI::load — Loads C declarations from a C header file
- FFI::memcmp — Compares memory areas
- FFI::memcpy — Copies one memory area to another
- FFI::memset — Fills a memory area
- FFI::new — Creates a C data structure
- FFI::scope — Instantiates an FFI object with C declarations parsed during preloading
- FFI::sizeof — Gets the size of C data or types
- FFI::string — Creates a PHP string from a memory area
- FFI::type — Creates an FFI\CType object from a C declaration
- FFI::typeof — Gets the FFI\CType of FFI\CData
- FFI\CData — C Data Handles
- FFI\CType — C Type Handles
- FFI\Exception — FFI Exceptions
- 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
- opcache_compile_file — Compiles and caches a PHP script without executing it
- opcache_get_configuration — Get configuration information about the cache
- opcache_get_status — Get status information about the cache
- opcache_invalidate — Invalidates a cached script
- opcache_is_script_cached — Tells whether a script is cached in OPCache
- 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
- flush — Flush system output buffer
- ob_clean — Clean (erase) the output buffer
- ob_end_clean — Clean (erase) the output buffer and turn off output buffering
- ob_end_flush — Flush (send) the output buffer and turn off output buffering
- ob_flush — Flush (send) the output buffer
- ob_get_clean — Get current buffer contents and delete current output buffer
- ob_get_contents — Return the contents of the output buffer
- ob_get_flush — Flush the output buffer, return it as a string and turn off output buffering
- ob_get_length — Return the length of the output buffer
- ob_get_level — Return the nesting level of the output buffering mechanism
- ob_get_status — Get status of output buffers
- ob_gzhandler — ob_start callback function to gzip output buffer
- ob_implicit_flush — Turn implicit flush on/off
- ob_list_handlers — List all output handlers in use
- ob_start — Turn on output buffering
- output_add_rewrite_var — Add URL rewriter values
- 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
- assert_options — Set/get the various assert flags
- assert — Checks if assertion is false
- cli_get_process_title — Returns the current process title
- cli_set_process_title — Sets the process title
- dl — Loads a PHP extension at runtime
- extension_loaded — Find out whether an extension is loaded
- gc_collect_cycles — Forces collection of any existing garbage cycles
- gc_disable — Deactivates the circular reference collector
- gc_enable — Activates the circular reference collector
- gc_enabled — Returns status of the circular reference collector
- gc_mem_caches — Reclaims memory used by the Zend Engine memory manager
- gc_status — Gets information about the garbage collector
- get_cfg_var — Gets the value of a PHP configuration option
- get_current_user — Gets the name of the owner of the current PHP script
- get_defined_constants — Returns an associative array with the names of all the constants and their values
- get_extension_funcs — Returns an array with the names of the functions of a module
- get_include_path — Gets the current include_path configuration option
- get_included_files — Returns an array with the names of included or required files
- get_loaded_extensions — Returns an array with the names of all modules compiled and loaded
- get_magic_quotes_gpc — Gets the current configuration setting of magic_quotes_gpc
- get_magic_quotes_runtime — Gets the current active configuration setting of magic_quotes_runtime
- get_required_files — Alias of get_included_files
- get_resources — Returns active resources
- getenv — Gets the value of an environment variable
- getlastmod — Gets time of last page modification
- getmygid — Get PHP script owner's GID
- getmyinode — Gets the inode of the current script
- getmypid — Gets PHP's process ID
- getmyuid — Gets PHP script owner's UID
- getopt — Gets options from the command line argument list
- getrusage — Gets the current resource usages
- ini_alter — Alias of ini_set
- ini_get_all — Gets all configuration options
- ini_get — Gets the value of a configuration option
- ini_restore — Restores the value of a configuration option
- ini_set — Sets the value of a configuration option
- main — Dummy for main
- memory_get_peak_usage — Returns the peak of memory allocated by PHP
- memory_get_usage — Returns the amount of memory allocated to PHP
- php_ini_loaded_file — Retrieve a path to the loaded php.ini file
- php_ini_scanned_files — Return a list of .ini files parsed from the additional ini dir
- php_sapi_name — Returns the type of interface between web server and PHP
- php_uname — Returns information about the operating system PHP is running on
- phpcredits — Prints out the credits for PHP
- phpinfo — Outputs information about PHP's configuration
- phpversion — Gets the current PHP version
- putenv — Sets the value of an environment variable
- restore_include_path — Restores the value of the include_path configuration option
- set_include_path — Sets the include_path configuration option
- set_time_limit — Limits the maximum execution time
- sys_get_temp_dir — Returns directory path used for temporary files
- version_compare — Compares two "PHP-standardized" version number strings
- zend_thread_id — Returns a unique identifier for the current thread
- 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:
- Step-Through Debugging
- Flexible Breakpoints (Class Method, Function, File:Line, Address, Opcode)
- Easy Access to PHP with built-in eval()
- Userland API
- SAPI Agnostic - Easily Integrated
- PHP Configuration File Support
- JIT Super Globals - Set Your Own !!
- Optional readline Support - Comfortable Terminal Operation
- Easy Operation - See Help :)
phpdbg Functions
- phpdbg_break_file — Inserts a breakpoint at a line in a file
- phpdbg_break_function — Inserts a breakpoint at entry to a function
- phpdbg_break_method — Inserts a breakpoint at entry to a method
- phpdbg_break_next — Inserts a breakpoint at the next opcode
- phpdbg_clear — Clears all breakpoints
- phpdbg_color — Sets the color of certain elements
- phpdbg_end_oplog — Description
- phpdbg_exec — Attempts to set the execution context
- phpdbg_get_executable — Description
- phpdbg_prompt — Sets the command prompt
- 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
- runkit7_constant_add — Similar to define(), but allows defining in class definitions as well
- runkit7_constant_redefine — Redefine an already defined constant
- runkit7_constant_remove — Remove/Delete an already defined constant
- runkit7_function_add — Add a new function, similar to create_function
- runkit7_function_copy — Copy a function to a new function name
- runkit7_function_redefine — Replace a function definition with a new implementation
- runkit7_function_remove — Remove a function definition
- runkit7_function_rename — Change a function's name
- runkit7_import — Process a PHP file importing function and class definitions, overwriting where appropriate
- runkit7_method_add — Dynamically adds a new method to a given class
- runkit7_method_copy — Copies a method from class to another
- runkit7_method_redefine — Dynamically changes the code of the given method
- runkit7_method_remove — Dynamically removes the given method
- runkit7_method_rename — Dynamically changes the name of the given method
- runkit7_object_id — Return the integer object handle for given object
- runkit7_superglobals — Return numerically indexed array of registered superglobals
- 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:
- Overloading some opcodes including ZEND_EXIT and ZEND_NEW
- Backup and restore functions and methods
- Renaming functions and methods
- Copying of functions and methods
- Deletion of functions and methods
- Redefinition of global and class constants
- Deletion of global and class constants
- Runtime composition and modification of classes
Uopz Functions
- uopz_add_function — Adds non-existent function or method
- uopz_allow_exit — Allows control over disabled exit opcode
- uopz_backup — Backup a function
- uopz_compose — Compose a class
- uopz_copy — Copy a function
- uopz_del_function — Deletes previously added function or method
- uopz_delete — Delete a function
- uopz_extend — Extend a class at runtime
- uopz_flags — Get or set flags on function or class
- uopz_function — Creates a function at runtime
- uopz_get_exit_status — Retrieve the last set exit status
- uopz_get_hook — Gets previously set hook on function or method
- uopz_get_mock — Get the current mock for a class
- uopz_get_property — Gets value of class or instance property
- uopz_get_return — Gets a previous set return value for a function
- uopz_get_static — Gets the static variables from function or method scope
- uopz_implement — Implements an interface at runtime
- uopz_overload — Overload a VM opcode
- uopz_redefine — Redefine a constant
- uopz_rename — Rename a function at runtime
- uopz_restore — Restore a previously backed up function
- uopz_set_hook — Sets hook to execute when entering a function or method
- uopz_set_mock — Use mock instead of class for new objects
- uopz_set_property — Sets value of existing class or instance property
- uopz_set_return — Provide a return value for an existing function
- uopz_set_static — Sets the static variables in function or method scope
- uopz_undefine — Undefine a constant
- uopz_unset_hook — Removes previously set hook on function or method
- uopz_unset_mock — Unset previously set mock
- 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.
-------------------------------------------------
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.
-
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.
-
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.
-
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.
-
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.
-
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.
- WinCache Functions
- wincache_fcache_fileinfo — Retrieves information about files cached in the file cache
- wincache_fcache_meminfo — Retrieves information about file cache memory usage
- wincache_lock — Acquires an exclusive lock on a given key
- wincache_ocache_fileinfo — Retrieves information about files cached in the opcode cache
- wincache_ocache_meminfo — Retrieves information about opcode cache memory usage
- wincache_refresh_if_changed — Refreshes the cache entries for the cached files
- wincache_rplist_fileinfo — Retrieves information about resolve file path cache
- wincache_rplist_meminfo — Retrieves information about memory usage by the resolve file path cache
- wincache_scache_info — Retrieves information about files cached in the session cache
- wincache_scache_meminfo — Retrieves information about session cache memory usage
- wincache_ucache_add — Adds a variable in user cache only if variable does not already exist in the cache
- wincache_ucache_cas — Compares the variable with old value and assigns new value to it
- wincache_ucache_clear — Deletes entire content of the user cache
- wincache_ucache_dec — Decrements the value associated with the key
- wincache_ucache_delete — Deletes variables from the user cache
- wincache_ucache_exists — Checks if a variable exists in the user cache
- wincache_ucache_get — Gets a variable stored in the user cache
- wincache_ucache_inc — Increments the value associated with the key
- wincache_ucache_info — Retrieves information about data stored in the user cache
- wincache_ucache_meminfo — Retrieves information about user cache memory usage
- wincache_ucache_set — Adds a variable in user cache and overwrites a variable if it already exists in the cache
- 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
- xhprof_disable — Stops xhprof profiler
- xhprof_enable — Start xhprof profiler
- xhprof_sample_disable — Stops xhprof sample profiler
- 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
- Yac::add — Store into cache
- Yac::__construct — Constructor
- Yac::delete — Remove items from cache
- Yac::dump — Dump cache
- Yac::flush — Flush the cache
- Yac::get — Retrieve values from cache
- Yac::__get — Getter
- Yac::info — Status of cache
- Yac::set — Store into cache
- Yac::__set — Setter
----------------------------------
Platform independent audio bindings. Requires the » OpenAL library.
- openal_buffer_create — Generate OpenAL buffer
- openal_buffer_data — Load a buffer with data
- openal_buffer_destroy — Destroys an OpenAL buffer
- openal_buffer_get — Retrieve an OpenAL buffer property
- openal_buffer_loadwav — Load a .wav file into a buffer
- openal_context_create — Create an audio processing context
- openal_context_current — Make the specified context current
- openal_context_destroy — Destroys a context
- openal_context_process — Process the specified context
- openal_context_suspend — Suspend the specified context
- openal_device_close — Close an OpenAL device
- openal_device_open — Initialize the OpenAL audio layer
- openal_listener_get — Retrieve a listener property
- openal_listener_set — Set a listener property
- openal_source_create — Generate a source resource
- openal_source_destroy — Destroy a source resource
- openal_source_get — Retrieve an OpenAL source property
- openal_source_pause — Pause the source
- openal_source_play — Start playing the source
- openal_source_rewind — Rewind the source
- openal_source_set — Set source property
- openal_source_stop — Stop playing the source
- 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.
- radius_acct_open — Creates a Radius handle for accounting
- radius_add_server — Adds a server
- radius_auth_open — Creates a Radius handle for authentication
- radius_close — Frees all ressources
- radius_config — Causes the library to read the given configuration file
- radius_create_request — Create accounting or authentication request
- radius_cvt_addr — Converts raw data to IP-Address
- radius_cvt_int — Converts raw data to integer
- radius_cvt_string — Converts raw data to string
- radius_demangle_mppe_key — Derives mppe-keys from mangled data
- radius_demangle — Demangles data
- radius_get_attr — Extracts an attribute
- radius_get_tagged_attr_data — Extracts the data from a tagged attribute
- radius_get_tagged_attr_tag — Extracts the tag from a tagged attribute
- radius_get_vendor_attr — Extracts a vendor specific attribute
- radius_put_addr — Attaches an IP address attribute
- radius_put_attr — Attaches a binary attribute
- radius_put_int — Attaches an integer attribute
- radius_put_string — Attaches a string attribute
- radius_put_vendor_addr — Attaches a vendor specific IP address attribute
- radius_put_vendor_attr — Attaches a vendor specific binary attribute
- radius_put_vendor_int — Attaches a vendor specific integer attribute
- radius_put_vendor_string — Attaches a vendor specific string attribute
- radius_request_authenticator — Returns the request authenticator
- radius_salt_encrypt_attr — Salt-encrypts a value
- radius_send_request — Sends the request and waits for a reply
- radius_server_secret — Returns the shared secret
- 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.
- ncurses_addch — Add character at current position and advance cursor
- ncurses_addchnstr — Add attributed string with specified length at current position
- ncurses_addchstr — Add attributed string at current position
- ncurses_addnstr — Add string with specified length at current position
- ncurses_addstr — Output text at current position
- ncurses_assume_default_colors — Define default colors for color 0
- ncurses_attroff — Turn off the given attributes
- ncurses_attron — Turn on the given attributes
- ncurses_attrset — Set given attributes
- ncurses_baudrate — Returns baudrate of terminal
- ncurses_beep — Let the terminal beep
- ncurses_bkgd — Set background property for terminal screen
- ncurses_bkgdset — Control screen background
- ncurses_border — Draw a border around the screen using attributed characters
- ncurses_bottom_panel — Moves a visible panel to the bottom of the stack
- ncurses_can_change_color — Checks if terminal color definitions can be changed
- ncurses_cbreak — Switch off input buffering
- ncurses_clear — Clear screen
- ncurses_clrtobot — Clear screen from current position to bottom
- ncurses_clrtoeol — Clear screen from current position to end of line
- ncurses_color_content — Retrieves RGB components of a color
- ncurses_color_set — Set active foreground and background colors
- ncurses_curs_set — Set cursor state
- ncurses_def_prog_mode — Saves terminals (program) mode
- ncurses_def_shell_mode — Saves terminals (shell) mode
- ncurses_define_key — Define a keycode
- ncurses_del_panel — Remove panel from the stack and delete it (but not the associated window)
- ncurses_delay_output — Delay output on terminal using padding characters
- ncurses_delch — Delete character at current position, move rest of line left
- ncurses_deleteln — Delete line at current position, move rest of screen up
- ncurses_delwin — Delete a ncurses window
- ncurses_doupdate — Write all prepared refreshes to terminal
- ncurses_echo — Activate keyboard input echo
- ncurses_echochar — Single character output including refresh
- ncurses_end — Stop using ncurses, clean up the screen
- ncurses_erase — Erase terminal screen
- ncurses_erasechar — Returns current erase character
- ncurses_filter — Set LINES for iniscr() and newterm() to 1
- ncurses_flash — Flash terminal screen (visual bell)
- ncurses_flushinp — Flush keyboard input buffer
- ncurses_getch — Read a character from keyboard
- ncurses_getmaxyx — Returns the size of a window
- ncurses_getmouse — Reads mouse event
- ncurses_getyx — Returns the current cursor position for a window
- ncurses_halfdelay — Put terminal into halfdelay mode
- ncurses_has_colors — Checks if terminal has color capabilities
- ncurses_has_ic — Check for insert- and delete-capabilities
- ncurses_has_il — Check for line insert- and delete-capabilities
- ncurses_has_key — Check for presence of a function key on terminal keyboard
- ncurses_hide_panel — Remove panel from the stack, making it invisible
- ncurses_hline — Draw a horizontal line at current position using an attributed character and max. n characters long
- ncurses_inch — Get character and attribute at current position
- ncurses_init_color — Define a terminal color
- ncurses_init_pair — Define a color pair
- ncurses_init — Initialize ncurses
- ncurses_insch — Insert character moving rest of line including character at current position
- ncurses_insdelln — Insert lines before current line scrolling down (negative numbers delete and scroll up)
- ncurses_insertln — Insert a line, move rest of screen down
- ncurses_insstr — Insert string at current position, moving rest of line right
- ncurses_instr — Reads string from terminal screen
- ncurses_isendwin — Ncurses is in endwin mode, normal screen output may be performed
- ncurses_keyok — Enable or disable a keycode
- ncurses_keypad — Turns keypad on or off
- ncurses_killchar — Returns current line kill character
- ncurses_longname — Returns terminals description
- ncurses_meta — Enables/Disable 8-bit meta key information
- ncurses_mouse_trafo — Transforms coordinates
- ncurses_mouseinterval — Set timeout for mouse button clicks
- ncurses_mousemask — Sets mouse options
- ncurses_move_panel — Moves a panel so that its upper-left corner is at [startx, starty]
- ncurses_move — Move output position
- ncurses_mvaddch — Move current position and add character
- ncurses_mvaddchnstr — Move position and add attributed string with specified length
- ncurses_mvaddchstr — Move position and add attributed string
- ncurses_mvaddnstr — Move position and add string with specified length
- ncurses_mvaddstr — Move position and add string
- ncurses_mvcur — Move cursor immediately
- ncurses_mvdelch — Move position and delete character, shift rest of line left
- ncurses_mvgetch — Move position and get character at new position
- ncurses_mvhline — Set new position and draw a horizontal line using an attributed character and max. n characters long
- ncurses_mvinch — Move position and get attributed character at new position
- ncurses_mvvline — Set new position and draw a vertical line using an attributed character and max. n characters long
- ncurses_mvwaddstr — Add string at new position in window
- ncurses_napms — Sleep
- ncurses_new_panel — Create a new panel and associate it with window
- ncurses_newpad — Creates a new pad (window)
- ncurses_newwin — Create a new window
- ncurses_nl — Translate newline and carriage return / line feed
- ncurses_nocbreak — Switch terminal to cooked mode
- ncurses_noecho — Switch off keyboard input echo
- ncurses_nonl — Do not translate newline and carriage return / line feed
- ncurses_noqiflush — Do not flush on signal characters
- ncurses_noraw — Switch terminal out of raw mode
- ncurses_pair_content — Retrieves foreground and background colors of a color pair
- ncurses_panel_above — Returns the panel above panel
- ncurses_panel_below — Returns the panel below panel
- ncurses_panel_window — Returns the window associated with panel
- ncurses_pnoutrefresh — Copies a region from a pad into the virtual screen
- ncurses_prefresh — Copies a region from a pad into the virtual screen
- ncurses_putp — Apply padding information to the string and output it
- ncurses_qiflush — Flush on signal characters
- ncurses_raw — Switch terminal into raw mode
- ncurses_refresh — Refresh screen
- ncurses_replace_panel — Replaces the window associated with panel
- ncurses_reset_prog_mode — Resets the prog mode saved by def_prog_mode
- ncurses_reset_shell_mode — Resets the shell mode saved by def_shell_mode
- ncurses_resetty — Restores saved terminal state
- ncurses_savetty — Saves terminal state
- ncurses_scr_dump — Dump screen content to file
- ncurses_scr_init — Initialize screen from file dump
- ncurses_scr_restore — Restore screen from file dump
- ncurses_scr_set — Inherit screen from file dump
- ncurses_scrl — Scroll window content up or down without changing current position
- ncurses_show_panel — Places an invisible panel on top of the stack, making it visible
- ncurses_slk_attr — Returns current soft label key attribute
- ncurses_slk_attroff — Turn off the given attributes for soft function-key labels
- ncurses_slk_attron — Turn on the given attributes for soft function-key labels
- ncurses_slk_attrset — Set given attributes for soft function-key labels
- ncurses_slk_clear — Clears soft labels from screen
- ncurses_slk_color — Sets color for soft label keys
- ncurses_slk_init — Initializes soft label key functions
- ncurses_slk_noutrefresh — Copies soft label keys to virtual screen
- ncurses_slk_refresh — Copies soft label keys to screen
- ncurses_slk_restore — Restores soft label keys
- ncurses_slk_set — Sets function key labels
- ncurses_slk_touch — Forces output when ncurses_slk_noutrefresh is performed
- ncurses_standend — Stop using 'standout' attribute
- ncurses_standout — Start using 'standout' attribute
- ncurses_start_color — Initializes color functionality
- ncurses_termattrs — Returns a logical OR of all attribute flags supported by terminal
- ncurses_termname — Returns terminals (short)-name
- ncurses_timeout — Set timeout for special key sequences
- ncurses_top_panel — Moves a visible panel to the top of the stack
- ncurses_typeahead — Specify different filedescriptor for typeahead checking
- ncurses_ungetch — Put a character back into the input stream
- ncurses_ungetmouse — Pushes mouse event to queue
- ncurses_update_panels — Refreshes the virtual screen to reflect the relations between panels in the stack
- ncurses_use_default_colors — Assign terminal default colors to color id -1
- ncurses_use_env — Control use of environment information about terminal size
- ncurses_use_extended_names — Control use of extended names in terminfo descriptions
- ncurses_vidattr — Display the string on the terminal in the video attribute mode
- ncurses_vline — Draw a vertical line at current position using an attributed character and max. n characters long
- ncurses_waddch — Adds character at current position in a window and advance cursor
- ncurses_waddstr — Outputs text at current postion in window
- ncurses_wattroff — Turns off attributes for a window
- ncurses_wattron — Turns on attributes for a window
- ncurses_wattrset — Set the attributes for a window
- ncurses_wborder — Draws a border around the window using attributed characters
- ncurses_wclear — Clears window
- ncurses_wcolor_set — Sets windows color pairings
- ncurses_werase — Erase window contents
- ncurses_wgetch — Reads a character from keyboard (window)
- ncurses_whline — Draws a horizontal line in a window at current position using an attributed character and max. n characters long
- ncurses_wmouse_trafo — Transforms window/stdscr coordinates
- ncurses_wmove — Moves windows output position
- ncurses_wnoutrefresh — Copies window to virtual screen
- ncurses_wrefresh — Refresh window on terminal screen
- ncurses_wstandend — End standout mode for a window
- ncurses_wstandout — Enter standout mode for a window
- 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.
- readline_add_history — Adds a line to the history
- readline_callback_handler_install — Initializes the readline callback interface and terminal, prints the prompt and returns immediately
- readline_callback_handler_remove — Removes a previously installed callback handler and restores terminal settings
- readline_callback_read_char — Reads a character and informs the readline callback interface when a line is received
- readline_clear_history — Clears the history
- readline_completion_function — Registers a completion function
- readline_info — Gets/sets various internal readline variables
- readline_list_history — Lists the history
- readline_on_new_line — Inform readline that the cursor has moved to a new line
- readline_read_history — Reads the history
- readline_redisplay — Redraws the display
- readline_write_history — Writes the history
- readline — Reads a line
------------------------------
Compression and Archive Extensions
The bzip2 functions are used to transparently read and write bzip2 (.bz2) compressed files.
Bzip2 Functions
- bzclose — Close a bzip2 file
- bzcompress — Compress a string into bzip2 encoded data
- bzdecompress — Decompresses bzip2 encoded data
- bzerrno — Returns a bzip2 error number
- bzerror — Returns the bzip2 error number and error string in an array
- bzerrstr — Returns a bzip2 error string
- bzflush — Do nothing
- bzopen — Opens a bzip2 compressed file
- bzread — Binary safe bzip2 file read
- bzwrite — Binary safe bzip2 file write
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.
- random_bytes — Generates cryptographically secure pseudo-random bytes
- random_int — Generates cryptographically secure pseudo-random integers
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() } //
- hash_algos — Return a list of registered hashing algorithms
- hash_copy — Copy hashing context
- hash_equals — Timing attack safe string comparison
- hash_file — Generate a hash value using the contents of a given file
- hash_final — Finalize an incremental hash and return resulting digest
- hash_hkdf — Generate a HKDF key derivation of a supplied key input
- hash_hmac_algos — Return a list of registered hashing algorithms suitable for hash_hmac
- hash_hmac_file — Generate a keyed hash value using the HMAC method and the contents of a given file
- hash_hmac — Generate a keyed hash value using the HMAC method
- hash_init — Initialize an incremental hashing context
- hash_pbkdf2 — Generate a PBKDF2 key derivation of a supplied password
- hash_update_file — Pump data into an active hashing context from a file
- hash_update_stream — Pump data into an active hashing context from an open stream
- hash_update — Pump data into an active hashing context
- hash — Generate a hash value (message digest)
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.
Predefined Constants
- MHASH_ADLER32
- MHASH_CRC32
- MHASH_CRC32B
- MHASH_GOST
- MHASH_HAVAL128
- MHASH_HAVAL160
- MHASH_HAVAL192
- MHASH_HAVAL224
- MHASH_HAVAL256
- MHASH_MD2
- MHASH_MD4
- MHASH_MD5
- MHASH_RIPEMD128
- MHASH_RIPEMD256
- MHASH_RIPEMD320
- MHASH_SHA1
- MHASH_SHA192
- MHASH_SHA224
- MHASH_SHA256
- MHASH_SHA384
- MHASH_SHA512
- MHASH_SNEFRU128
- MHASH_SNEFRU256
- MHASH_TIGER
- MHASH_TIGER128
- MHASH_TIGER160
- MHASH_WHIRLPOOL
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:
-
salt (string) - to manually provide a salt to use when hashing the password. Note that this will override and prevent a salt from being automatically generated.
If omitted, a random salt will be generated by password_hash() for each password hashed. This is the intended mode of operation and as of PHP 7.0.0 the salt option has been deprecated.
-
cost (int) - which denotes the algorithmic cost that should be used. Examples of these values can be found on the crypt() page.
If omitted, a default value of 10 will be used. This is a good baseline cost, but you may want to consider increasing it depending on your hardware.
- PASSWORD_ARGON2I (string)
-
PASSWORD_ARGON2I is used to create new password hashes using the Argon2i algorithm.
Supported Options:
-
memory_cost (int) - Maximum memory (in bytes) that may be used to compute the Argon2 hash. Defaults to PASSWORD_ARGON2_DEFAULT_MEMORY_COST.
-
time_cost (int) - Maximum amount of time it may take to compute the Argon2 hash. Defaults to PASSWORD_ARGON2_DEFAULT_TIME_COST.
-
threads (int) - Number of threads to use for computing the Argon2 hash. Defaults to PASSWORD_ARGON2_DEFAULT_THREADS.
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:
- PHP 5.5.0 - PASSWORD_BCRYPT
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
- DBA — Database (dbm-style) Abstraction Layer
- ODBC — ODBC (Unified)
- PDO — PHP Data Objects
Vendor Specific Database Extensions
Abstraction Layers
-
1. DBA — Database (dbm-style) Abstraction Layer
These functions build the foundation for accessing Berkeley DB style databases.
-
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. 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
exec ( string $statement ) : int
public
quote ( string $string , int $parameter_type = PDO::PARAM_STR ) : string
}
---------------------------
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.
----------------------------------------------------------------------------
PDO Drivers