10 little-known but very useful functions in php

Source: Internet
Author: User
PHP has a rich set of built-in functions that we have used. However, most of us are not familiar with, but they are very useful. In this article, I have listed some little-known PHP functions that will highlight your eyes. PHP has a rich set of built-in functions that we have used. However, most of us are not familiar with, but they are very useful. In this article, I have listed some little-known PHP functions that will highlight your eyes.

Levenshtein ()

Have you ever experienced how different the two words are? this function helps you solve this problem. It can compare different degrees of two strings.

Usage:

 

Source: http://php.net/manual/en/function.levenshtein.php

Get_defined_vars ()

This is a very useful function in debug debugging. This function returns a multi-dimensional array containing all defined variables.

Usage:

 

Source: http://php.net/manual/en/function.get-defined-vars.php

Php_check_syntax ()

This function is very useful and can be used to check whether PHP syntax is correct. Technically, this function has been deleted since PHP 5.05.

Usage:

 

Source: http://www.php.net/manual/en/function.php-check-syntax.php

Ignore_user_abort ()

This function is used to deny the browser user's request to terminate the script execution. Under normal circumstances, the exit of the client will cause the script on the server to stop running.

Usage:

 

Source: http://www.php.net/manual/en/function.ignore-user-abort.php

Highlight_string ()

When you want to display PHP code to the page, the highlight_string () function is very useful. This function will highlight the defined color of your PHP code with the built-in PHP syntax. This function has two parameters. The first parameter is a string, indicating that the string needs to be highlighted. If the second parameter is set to TRUE, the highlighted code is returned as the return value.

Usage

 '); ?>

Source: http://php.net/manual/en/function.highlight-string.php

Highlight_file

This is a very useful PHP function. it can return the specified PHP file and highlight the file content in a highlighted color according to syntax. The highlighted codes are all processed with HTML tags.

Usage:

 

Source: http://www.php.net/manual/en/function.highlight-file.php

Php_strip_whitespace

This function is similar to the show_source () function, but it deletes comments and space characters in the file.

Usage:

 

Source: http://www.php.net/manual/en/function.php-strip-whitespace.php

Get_browser

This function reads the browscap. ini file and returns browser compatibility information.

Usage:

 

Source: http://www.php.net/manual/en/function.get-browser.php

Memory_get_usage (), memory_get_peak_usage (), getrusage ()

These functions are used to obtain the memory and CPU usage. the memory_get_usage () function returns the memory usage, the memory_get_peak_usage () function returns the memory usage peak, and the getrusage () function returns the CPU usage, when debugging PHP code performance, these functions provide you with some useful information. Note that Window is invalid in these functions.

Usage:

 

Gzcompress (), gzuncompress ()
These two functions are used to compress and decompress string data. Their compression ratio can reach about 50%. In addition, the gzencode () and gzdecode () functions can achieve similar results, but different compression algorithms are used.

Usage:

 

Have you thought of other useful functions? Please share it in the comments!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.