Explaining PHP function use is smoother when methods can be categorized into clear groups. However, some single functions and constants stand alone and don't belong to any specific categories.
Even though such functions are not a part of a chain of similar methods, they still need to be addressed. Therefore, we dedicate a tutorial to PHP miscellaneous functions.
PHP Function Use: Main Tips
- PHP miscellaneous functions are functions which just don't fit into the other major categories.
- They can prove useful in PHP configuration or other tasks.
- Every function in this tutorial is a PHP built in function.
The way PHP miscellaneous functions behave always depends on the settings inside the php.ini file. Let's have a look at the options we have for PHP configuration using miscellaneous functions:
|ignore_user_abort||FALSE will indicate that script is to be terminated as soon as the user tries to output something after the client has aborted their connection||"0"||PHP_INI_ALL|
|highlight.string||Colored highlight for PHP string||"#DD0000"||PHP_INI_ALL|
|highlight.comment||Colored highlight PHP comment||"#FF8000"||PHP_INI_ALL|
|highlight.keyword||Colored highlight for PHP keyword (e.g. parenthesis, semicolon)||"#007700"||PHP_INI_ALL|
|highlight.bg||Colors the background [Deprecated since PHP 5.4]||"#FFFFFF"||PHP_INI_ALL|
|highlight.default||Set colored highlight to default color in PHP.||"#0000BB"||PHP_INI_ALL|
|highlight.html||Colored highlight for HTML code.||"#000000"||PHP_INI_ALL|
|browscap||Filename and directory of the browser-capabilities file (e.g. browscap.ini)||NULL||PHP_INI_SYSTEM|
Theory is great, but we recommend digging deeper!
List of Methods
In this section, you will be informed of the PHP function use of this miscellaneous category. For instance, you can set a function to be executed later with the PHP
sleep() method. There are many methods to analyze in the table below. However, we are sure that some of them will prove themselves to be useful.
|connection_aborted()||Check whether client has disconnected|
|connection_status()||Return current connection status|
|connection_timeout()||Check whether script has timed out [Deprecated since PHP 4.0.5]|
|constant()||Return value of constant|
|defined()||Check whether constant exists|
|die()||Print message and exits current script|
|eval()||Evaluate string as PHP code|
|exit()||Print message and exits current script|
|get_browser()||Return capabilities of user's browser|
|__halt_compiler()||Halt compiler execution|
|highlight_file()||Output file with PHP syntax highlighted|
|highlight_string()||Output string with PHP syntax highlighted|
|ignore_user_abort()||Set whether remote client can abort running of script|
|pack()||Pack data into binary string|
|php_check_syntax()||[Deprecated since PHP 5.0.5]|
|php_strip_whitespace()||Return source code of file with PHP comments and whitespace deleted|
|show_source()||Alias for the highlight_file() function|
|sleep()||Delay code execution for number of seconds|
|sys_getloadavg()||Get system load average|
|time_nanosleep()||Delay code execution for number of seconds and nanoseconds|
|time_sleep_until()||Delay code execution until specified time|
|uniqid()||Generate unique ID|
|unpack()||Unpack data from binary string|
|usleep()||Delay code execution for number of microseconds|
This list below contains the constant names, descriptions and versions in which these PHP constants can be executed:
|CONNECTION_ABORTED||Checks if the client has disconnected||4 and newer|
|CONNECTION_NORMAL||Checks status of the connection||4 and newer|
|CONNECTION_TIMEOUT||Checks if the connection has timed out||4.0.5. and older [Deprecated]|
|__COMPILER_HALT_OFFSET__||Checks byte position of the data start||5.1. and newer|
PHP Function Use: Summary
- All the functions that just don't seem to belong to any particular category are defined as PHP miscellaneous functions.
- While they stand alone, every miscellaneous PHP built in function is still very useful in the process of PHP configuration.
- If you are using PHP 5 or a newer version, none of these functions require installation.