PHP Function Get_Debug_Type
PHP has a lot of new features and improvements in PHP 8. These changes can have a great impact on your day to day programming. But, if you’re not ready to update your code for these changes then you can use a simple function to get a similar effect. This function is called php function get_debug_type.
This is a very simple and easy to use function. This function will return the type name of a variable. It works similarly to the native gettype() function. But, this function will give you more detailed information for arrays, strings, anonymous classes, and objects.
Also, this function will resolve the class name of objects, scalar values to their native type names, and resource types to their type name, just like in PHP 7. This will help you debug better.
Another important feature that will make your life easier is named arguments. This is a new way to pass parameters into a function based on their order rather than the position. This will save a lot of time and confusion because you won’t need to copy all the default arguments that come before your own, but you can simply assign them by their name.
Finally, PHP has added support for union types. These are a collection of two or more types that indicate that either one can be used. This feature is not completely complete as it only supports void and integer types, but it’s a start. It will be great to see more support for these kinds of types in the future.