Skip to content

php_ref_misc

This section covers various PHP functions that don’t neatly fit into other specific categories like String Manipulation, Arrays, or Math. They handle tasks related to script execution control, information gathering, constant handling, and data serialization.

These miscellaneous functions are part of the PHP core. No separate installation or extension enabling is needed to use them.

Some miscellaneous functions’ behavior can be influenced by settings in the php.ini configuration file.

DirectiveDescriptionDefault ValueChangeable Scope
ignore_user_abortIf enabled ("1"), the script continues running even if the client disconnects. If disabled ("0"), the script may terminate when it tries to send output after the client has disconnected."0"PHP_INI_ALL
highlight.stringColor used for strings in syntax highlighting functions (highlight_string, highlight_file).#DD0000PHP_INI_ALL
highlight.commentColor used for comments.#FF8000PHP_INI_ALL
highlight.keywordColor used for PHP keywords.#007700PHP_INI_ALL
highlight.defaultDefault color for syntax elements.#0000BBPHP_INI_ALL
highlight.htmlColor used for HTML outside PHP blocks.#000000PHP_INI_ALL
browscapPath to the browser capabilities file (browscap.ini) used by get_browser(). Requires downloading the file separately.NULLPHP_INI_SYSTEM
FunctionDescription
connection_aborted()Checks if the client connection has been dropped.
connection_status()Returns the connection status bitmask (e.g., normal, aborted, timeout).
constant()Returns the value of a constant specified by a string name. Useful for dynamic access.
define()Defines a named constant at runtime.
defined()Checks if a named constant exists.
die() / exit()Outputs a message and terminates the current script. die() is an alias of exit().
eval()Evaluates a string as PHP code. Use with extreme caution due to security risks.
get_browser()Attempts to determine the capabilities of the user’s browser based on the browscap setting in php.ini.
__halt_compiler()Stops the compiler execution. Useful for embedding data within PHP scripts after this directive.
highlight_file() / show_source()Outputs a file with PHP syntax highlighting. show_source() is an alias.
highlight_string()Outputs a string with PHP syntax highlighting.
ignore_user_abort()Sets whether a script should abort when the client disconnects.
pack()Packs data into a binary string according to a format string.
php_strip_whitespace()Returns the source code of a file with PHP comments and whitespace removed.
sleep()Delays script execution for a specified number of seconds.
usleep()Delays script execution for a specified number of microseconds.
time_nanosleep()Delays execution for seconds and nanoseconds. Returns status.
time_sleep_until()Delays script execution until a specified timestamp.
uniqid()Generates a unique ID based on the current time in microseconds. Can be prefixed or have more entropy added.
unpack()Unpacks data from a binary string according to a format string.
sys_getloadavg()(Not available on Windows) Gets the system load average.
password_hash()(Security Category) Creates a secure hash of a password using strong, modern algorithms (like bcrypt). Essential for storing passwords.
password_verify()(Security Category) Verifies that a given password matches a stored hash created by password_hash(). Essential for checking passwords.
getenv()Gets the value of an environment variable.

Note: Some functions listed might have limited availability depending on the operating system or PHP configuration.

These constants are often used with connection status functions.

ConstantDescription
CONNECTION_ABORTEDBitmask value indicating the connection was aborted.
CONNECTION_NORMALBitmask value indicating the connection is still active.
CONNECTION_TIMEOUTBitmask value indicating the connection timed out.
__COMPILER_HALT_OFFSET__(PHP 5.1+) Contains the byte offset of the data section after __halt_compiler() if used.