Home >Backend Development >PHP Tutorial >10 little-known functions in PHP_PHP Tutorial
There are a lot of built-in functions in PHP, many of which we have used, but there are still many functions that most of us are not familiar with, but they are very useful. In this article, I list some little-known PHP functions that will make your eyes bright.
levenshtein()
Have you ever experienced a time when you needed to know how different two words are? This function is here to help you solve this problem. It can compare the degree of difference between two strings.
Usage:
This is a very useful function during debugging. This function returns a multidimensional array containing all defined variables.
Usage:
This function is very useful and can be used to check whether the syntax of PHP is correct. For technical reasons, this function has been removed starting with PHP 5.05.
Usage:
This function is used to reject the browser user's request to terminate script execution. Under normal circumstances, the client's exit will cause the server-side script to stop running.
Usage:
The highlight_string() function is very useful when you want to display PHP code on the page. This function will highlight the PHP code you provide using the color defined by the built-in PHP syntax highlighting. This function has two parameters. The first parameter is a string, indicating that this string needs to be highlighted. If the second parameter is set to TRUE, this function will return the highlighted code as the return value.
Usage:
This is a very useful PHP function that returns the specified PHP file and highlights the file content with a highlight color according to the syntax and semantics. The highlighted code is processed using HTML markup.
Usage:
This function is also similar to the previous show_source() function, but it will delete comments and spaces in the file.
Usage:
This function will read the browsercap.ini file and return browser compatibility information.
Usage:
These functions are used to obtain memory and CPU usage. The memory_get_usage() function returns the memory usage, the memory_get_peak_usage() function returns the peak memory usage, and getrusage() returns the CUP usage. When debugging PHP code performance, these functions will Provide you with some useful information. But please note that these functions are not valid on Windows.
Usage:
These two functions are used to compress and decompress string data. Their compression rate can reach about 50%. The other functions gzencode() and gzdecode() can achieve similar results, but use different compression algorithms.
Usage: