[7] PHP8 New str_starts_with and str_ends_with, fdiv, get_debug_type
This is the seventh part of the series and in the current post, I want to go through the str_starts_with and str_ends_with, fdiv, get_debug_type functions of PHP8. You can see the full list of features here. Furthermore, you can read the sixth part of the series here.
The str_starts_with
and str_ends_with functions
PHP8 introduces several new functions into the language. The str_starts_with and the str_ends_with functions are new string-related functions. They return a boolean value based on whether the string is available or not, in the beginning, or at the end of the other string.
str_starts_with('haystack', 'hay'); // true
str_ends_with('haystack', 'stack'); // true
The fdiv function
The new fdiv()
function allows division by zero without throwing an error. Instead of the error, it will return with INF, -INF, and NAN depending on the case.
The get_debug_type functions
The get_debug_type function returns type information. It is similar to the gettype function but the returning information is much more detailed when we use it with arrays, strings, anonymous classes, and objects.
Useful Topic related Links
The previous part of the series
PHP 8.0 DateTime objects ‘From’ interface, Stringable interface and str_contains function