Home  >  Article  >  Backend Development  >  Collection and sharing of some PHP functions

Collection and sharing of some PHP functions

小云云
小云云Original
2018-03-29 11:47:471278browse

This article mainly shares with you some of the functions of PHP. I hope it can help you.

1.Gettype():Get the variable type

2.Is_Array():Judge whether the variable is an array type

3.Is_double():Judge whether the variable is a double floating point type

4.Is_float():Judge whether the variable is a floating point type

5.Is_int():Judge whether the variable is of integer type

6.Is_integer():Judge whether the variable is of integer type

7.Is_long():Judge whether the variable is a long integer type

8.Is_object():Judge whether the variable is an object type

9 .Is_string():Determine whether the variable is of string type

10.EchoFunction: Output one or more strings

11. PrintFunction: Output one or more strings

12.DieFunction: This functional formulaexit() Alias ​​function of function

13.Printf function: This function is used to output a formatted string

Note: The first function is required and specifies the string and how to format the variables in it.

14.Trim function: used to remove spaces at the beginning and end of a string, and return the string after removing the spaces.

15.Ltrim function: This function is the same as the Trim() function, which only removes specific characters on the left side of the string.

16.Rtrim

function: This function is the same as the Trim() function and only removes specific characters on the right side of the string.

17.Str_pad()

Function: Fill in the string as required

Note: This function has four parameters, the first parameter is required. The second parameter is also required, the third function specifies the string used for padding, which is optional, and the fourth function specifies the direction of padding.

Example: $input = “Alien”;

echo str_pad($input,10);

Output:Alien

18.Addslashes()

: Used to add escape characters to special characters in the string.

19.Strlen()

Function: Get the length of a string.

20.Substr()

Function: Returns the substring of a string.

21.nl2br function: Insert HTML newline character "
" before each new line "\n" in the string

22.htmlspecialchars()

Function : Convert some predefined characters into HTML entities

23.Strcmp()

: String comparison function, press Compare strings in byte order

24.Strcasecmp(): The string comparison function can ignore the case of letters in the string for comparison

25.Strnatcmp(): Sort by nature The method compares two strings. This function is case-sensitive, and its usage formula is similar to the strcmp() function

26.Substr_replace: replaces the string of the string.

27.Strrev: This function can conveniently flip the string. It is only valid in English.

28.Num_format() function: Format numbers by thousands grouping.

29.Md5(): Encrypt a string with the MD5 algorithm. By default, it returns a 32-digit hexadecimal string that cannot be decrypted after encryption.

30.Mb_strlen function: Chinese and English When calculating the length of a mixed string, the number of characters is calculated instead of the number of bytes.

31.mb_substr function: String interception

32.each function: Return to the array The current key/value pair and moves the array pointer forward one step

33.list function: assign the values ​​​​in the array to some variables

34.explode() function: string Convert to an array

35.implode() function: Convert the array into a new string

36.count() function: Calculate the number of elements in the array or the number of attributes in the object

37.array_search() function: Query the specified element in the array

38. array_pop function: Get the last unit in the array

39.array_push function: Add elements to the array

40.array_unique() function: Used to delete duplicate values ​​in the array. This function only One parameter

41.array_rand() function: randomly extract array elements

42.sort() function: sort by key value in ascending order

43.rsort() function: press key Value sorting in descending order

44.ksort() function: Sort the array from small to large according to the key name

45.krsort() function: Sort the array from large to large according to the key name Sort in order of smallest order, and retain the original key names in the array after sorting

46.asort() function: Sort the array and maintain the index relationship

47. arsort() function: Sort the array in reverse and maintain the index relationship

48.natsort() function: Use "natural sortingAlgorithm to sort arrays

49.array_slice: Take out a value in the array based on conditions and return it

50.array_combine: By merging two Array to create a new array

51.array_merge: Merge one or more arrays into one array

52.foreach: A simple method to traverse an array, can only be used for arrays and objects.

53.each: Returns the current key/value of the array and moves the array pointer forward one step.

54.var_dump: Output variable type.

55.$_SERVER: Storage server related information

56.$_COOKIE: Client cookie information

57.$_SESSION: Stored program session information

58.$_FILES: Stores basic information about uploaded files

59.$_GET: Stores form information submitted in get mode

60.$_POST: Stores form information submitted in post mode Form information

61.array_values(): Get the value of the array

62.array_keys():Get the key name of the array

63.array_flip(): The values ​​in the array are interchanged with the key names (if there are duplicates, the previous ones will be overwritten by the later ones) )

64.in_array():Detect a string in the array

Related recommendations :

Very useful PHP functions

PHP functions How to use static variables

#Introduction to PHP function examples

The above is the detailed content of Collection and sharing of some PHP functions. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn