PHP trim() string function PHP trim() function The php trim() string function is used to remove whitespace and predefined character from both side of a given string.