Having arrived here from a Google search while trying to do this in Twig rather than PHP, I thought it might help someone in future to leave an answer, even though it doesn't address your question directly:
{{ item is instance of('craft\\elements\\Entry') ? 'This element is an entry!' }}
{{ item is instance of('craft\\elements\\Asset') ? 'This is an asset!' }}
{{ item is instance of('craft\\elements\\Category') ? 'This is a category!' }}
{{ item is instance of('craft\\elements\\User') ? 'This is a user!' }}
{{ item is instance of('craft\\commerce\\elements\\Product') ? '' }}
I find this especially useful in, for example, internal keyword search results listings templates, where the elements that were found might be of different types and you want to take different actions depending on the types.
Edit 2024 to add: You can also fetch the element type a little more succinctly like this, however (and it's a big HOWEVER!), beware that this requires a database query - so if you're inside a loop, which is probably quite likely given the use case for this, it's going to give you a horrible N+1 problem which will slow down your template:
{# you probably shouldn't do this due to the N+1 problem it'll cause : #}
{{ craft.app.elements.getElementTypeById(item.id) }}