PHP Common function usage

Source: Internet
Author: User

    1. Php_strip_whitespace (parameter 1 path of PHP file)

        1. -Returns the PHP source after deleting comments and spaces, and returns the PHP source after deleting comments and spaces filename .

        2. This is useful for comparing the actual number of code with the number of comments. This function is similar to executing php-w under the command line .

    2. Var_export (parameter 1 passed in string, parameter 2 is true)- outputs or returns a string representation of a variable

        1. The second argument of the function is set TRUE to return the representation of the variable.

    3. Token_get_all ($source a parameter for the PHP source code or the contents of the file)

        1. Split the provided source code into PHP markup

        2. More quotes when splitting

    4. Base64_encode (String $data, one parameter requires encoded data)

        1. This encoding is designed so that binary data can be transmitted over a non-pure 8-bit Transport Layer

        2. base64-encoded data takes up about 33% more space than the original data.

    5. Chunk_split (parameter 1 is the character to be split, the dimension of parameter 2 is split, the parameter 3 is the line end sequence symbol)

        1. The return value is the split string

        2. Splitting a string into small chunks

        3. General and Base64_encode a piece of use

    6. Realpath (parameter 1)

        1. Returns the normalized absolute path name

        2. Parameter 1 the path to check

    7. Json_decode (parameter 1, parameter 2, parameter 3, parameter 4)

        1. Encode a string in JSON format

        2. Parameter 1 string encoded in JSON string with decoding

        3. Parameter 2 returns an array instead of an object when True

        4. Parameter 3 (int $depth =512) Parameter 4 sets the large integer to float by default

    8. Json_encode (parameter 1, parameter 2)

      1. JSON encoding of the variable, successfully returns a JSON form is a string, no side returns false

      2. Parameter 1 The value to be encoded, except for any type other than the resource type, to accept only UTF-8 encoded data

      3. Parameter 2 consists of constants consisting of a binary mask:

      4. JSON_HEX_TAG(integer)

      5. All < and > convert to \u003c and \u003e. Effective from PHP 5.3.0.

      6. JSON_HEX_AMP(integer)

      7. All & Convert to \u0026. Effective from PHP 5.3.0.

      8. JSON_HEX_APOS(integer)

      9. All the ' converted into \u0027. Effective from PHP 5.3.0.

      10. JSON_HEX_QUOT(integer)

      11. All of the "converted into \u0022. Effective from PHP 5.3.0.

      12. JSON_FORCE_OBJECT(integer)

      13. Causes a non-associative array to output a class (Object) instead of an array. This is especially useful when the array is empty and the recipient needs a Class (Object). Effective from PHP 5.3.0.

      14. JSON_NUMERIC_CHECK(integer)

      15. Encodes all numeric strings into numbers (numbers). Effective from PHP 5.3.3.

      16. JSON_BIGINT_AS_STRING(integer)

      17. Encodes a large number into the original value of a primitive character. Effective from PHP 5.4.0.

      18. JSON_PRETTY_PRINT(integer)

      19. Formats the returned data with whitespace characters. Effective from PHP 5.4.0.

      20. JSON_UNESCAPED_SLASHES(integer)

      21. Do not encode /. Effective from PHP 5.4.0.

      22. JSON_UNESCAPED_UNICODE(integer)

      23. To literally encode multibyte Unicode characters (the default is to encode into \uxxxx). Effective from PHP 5.4.0.

    9. Uniqid (parameter 1, parameter 2)

        1. Generates a unique ID based on the unique ID of the current time's subtle number

        2. Parameter 1 Returns a string length of 13

        3. Parameter 2 if More_entropy=true adds an additional fan at the end of the returned string

    10. Http_build_query (parameter 1, parameter 2, parameter 3, parameter 4)

        1. Request string after generating Url-encode

        2. Parameter 1 can be an array or an object containing properties (only public will join)

        3. Parameter 2 parameter 3 parameter 4 omitted

    11. Spl_autoload_register (parameter 1)

        1. Registration __autoload () function returns true otherwise false

        2. Parameter 1 auto-load function to register, if no function is provided, the default implementation function of AutoLoad is automatically registered spl_autoload ()

    12. Get_headers (parameter 1, parameter 2)

        1. Gets the server response to all headers sent by an HTTP request, successfully returning an index or associative array, and failing to return false

        2. Parameter 1 destination URL

        3. Parameter 2 if set to 1get_headers () resolves the corresponding information and sets the array's key name

    13. Ini_set (parameter 1, parameter 2)

        1. Sets a value for a configuration option, returns the old value successfully, and returns false for failure

        2. Parameter 1 is fixed for certain values

        3. Parameter 2 option new value

    14. Strpos (parameter 1, parameter 2, parameter 3)

        1. Finds the first occurrence of a string where the current position is returned (default starting from 0), and the failure returns false

        2. Parameter 1 finds in this string

        3. Parameter 2 if Neddle is not a string, then he will be converted to a sequence value that is treated as a character

        4. Parameter 3 if given, the search starts from the beginning of the character string and cannot be a negative number.

    15. bool defined (str parameter 1)

        1. Detects whether a constant of a name exists, returns True, and returns false

        2. Parameter 1, the name of the constant

    16. SHA1 (parameter 1, parameter 2)

        1. Computes the SHA1 hash value of a string, returning the SHA1 hash value string

        2. Parameter 1, input string

        3. Parameter 2, if True then the SHA1 digest will be returned in the original format of 20 character length, otherwise the return value is a 40 string length of 16 binary digits

    17. Mcrypt_encrypt (parameter 1, parameter 2, parameter 3, parameter 4)

        1. Encrypts plaintext with the given parameters, returns the encrypted ciphertext, and fails to return false

        2. Parameter 1, the algorithm name of the string value or MCRYPT_ciphername a mcrypt_rijndael_128 in the constant

        3. Parameter 2, the encryption key, if the length is not the effective length that the algorithm can support, the function will issue a warning and return false

        4. Parameter 3, the string that needs to be encrypted

        5. Parameter 4, MCRYPT_MODE_modename one of the constants, or one of the following strings: "ECB", "CBC", "CFB", "OFB", "NOFB" and "stream". Mcrypt_mode_cbc

        6. Parameter 5, $iv = Mcrypt_create_iv ($iv _size, Mcrypt_rand);

    18. List (parameter 1, parameter 2, parameter 3)

        1. Assigns the values in the array to some variables, returning the specified array

        2. Parameter 11 variables

        3. ? $info = Array (' coffee ', ' brown ', ' caffeine ');
          List ($a [0], $a [1], $a [2]) = $info;

PHP Common function usage

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.