I couldn’t find either of these functions that satisfied my edge cases or desire for simplicity so I wrote/adapted some of my own. Feel free to use, modify, distribute without attribution, but I’d be eternally grateful if you did
The test for integer is adapted from this post, which is actually almost spot on, apart from their is_int() returns true, as does any integer in a string.
I’m pretty sure I’ve seen this test for string a hundred times on the internet and in books. It is by far the most robust:
Please let me know if you can break it!