PHP

100 PHP Functions You Should Know – Part 28 min read

In this tutorial we will discover the list of the 100 most used native functions in PHP.

51. fclose

Close an open file. This function returns TRUE on success or FALSE on failure.

 

52. is_int




Is used to test whether the type of the specified variable is an integer or not.

 

53. is_file

Checks whether the specified file is a regular file. This function returns TRUE if it is a file.

 

54. array_slice

Returns the selected parts of an array.

 

55. preg_match_all

Match all occurrences of the pattern in the string.

Output:

 

56. ucfirst

Converts the first character of a string to uppercase.

 

57. intval

Is used to retrieve the entire part of a value.

 

58. str_repeat

Repeats a string according to the number provided in parameter.

 

59. serialize

Converts a storable representation of a value.

 

60. array_filter

filters the values of an array using a callback function.

61. mkdir

Create a new directory.

 

62. is_callable

Is used to test only the contents of a variable, whether it can be called as a function or not.

 

63. ltrim

Removes spaces or other predefined characters to the left of a string.

 

64. ob_start

PHP being an interpreted language, each statement is executed one after the other. PHP therefore tends to send HTML code to browsers in chunks, which reduces performance. Using buffering, the generated HTML code is stored in a buffer or variable of type string and is sent to the buffer for rendering after the execution of the last statement of the PHP script.

But buffering is not enabled by default. To activate it, you must first use the ob_start() function in the script.

 

65. round

Round off a floating point number

 

66. fwrite

Writes to an open file. This function returns the number of bytes written.

 

67. array_unique

Removes duplicates from a table. If two or more values ​​are the same, the first will be kept and the other will be deleted.

 

68. array_search

Finds a value in an array and returns the key.

 

69. reset

Moves the internal pointer to the first element of the array.

 

70. array_unshift

Inserts new elements into an array. The new values ​​will be inserted at the beginning of the table.

71. parse_url

Processes a URL and reviews its components

Output:

 

72. func_get_args

Returns the arguments of a function in the form of an array.

 

73. end

Moves the internal pointer to the end of the array.

 

74. base64_encode

Encodes the data supplied with base64. This encoding is designed to ensure that binary data survives transport through unclean transport layers.

 

75. unserialize

Converts serialized data to real data.

 

76. max

Return the largest value in an array.

 

77. preg_split

Converts a string to an array according to the regular expression supplied as a parameter.

 

78. gettype

Is used to retrieve the type of a variable.

 

79. strrpos

Finds the position of the last occurrence of a string within another string.

 

80. version_compare

Compare the two standardized versions of PHP.

 

81. array_push

Inserts one or more elements at the end of an array.

 

82. floor

Rounds a number to the nearest whole number, if necessary.

 

83. strtotime

Converts a textual date-time to English in a Unix timestamp.

 

84. htmlspecialchars

Converts some predefined characters to HTML entities.

 

85. ini_get

The configuration settings are in the php.ini file. The defined value of each parameter can be identified using the ini_get function.

 

86. ini_set

The configuration settings are in the php.ini file. The defined value of each parameter can be modified using the ini_set function.

 

87. extension_loaded

This function returns TRUE if the extension identified by its name is loaded, otherwise returns FALSE.

 

88. is_bool

This function is used to determine whether a variable is a Boolean or not.

 

89. ksort

Sorts an associative array in ascending order, by key.

 

90.  Extension_loaded

This function returns TRUE if the extension identified by its name is loaded, otherwise returns FALSE.

91. array_reverse

Returns an array in reverse order.

 

92. ord

Returns the ASCII value of the first character of a string.

 

93. uniqid

Generate a unique identifier.

 

94. strtr

Replaces a substring in a string with a character string.

 

95. array_diff

Compares the values of two (or more) arrays and returns the differences.

 

96. error_reporting

Specifies which errors are reported.

 

97. ceil

Rounds a number to the nearest whole number, if necessary.

 

98. urlencode

This function is useful when encoding a string for use in a request part of a URL, as it is a convenient way to pass variables to the next page.

 

99. min

Returns the smallest value in an array.

 

100. print_r

Is used to display the contents of a variable in a readable way.

 

 

 

 

The 100 PHP Functions You Should Know – Part 1

 

 

Leave a Comment