What would be the best (most efficient, easiest to understand in the code, etc) way to check whether a variable is of primitive type in PHP?
Should I go the "positive" (e.g. is_string() || is_int()...)
way, or vice versa !is_array() && __is_object()..
or maybe some even fancier way?
You are looking for is_scalar().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With