6

In Java (well, Android's version at least) all objects have a getClass() method which returns the object's class and you can then call getSimpleName() to get the human-readable name of the object. This is great for logging. I'd like to be able to do something similar in a PHP program I've been working on. Is there any way to find out what type of object "this" is?

2
  • 1
    in Java getClass() is a method on the class Object, the root of the object inheritance hierarchy. So it's there even if you aren't on Android. :) Commented Dec 29, 2009 at 18:43
  • I assumed that was probably the case, but I haven't done any Java work outside of Android so I wasn't certain (and was too lazy to look it up). Commented Dec 29, 2009 at 18:45

2 Answers 2

22
return get_class($this);
Sign up to request clarification or add additional context in comments.

Comments

1

I think this php.net man page may have the answers your looking for: http://php.net/manual/en/function.get-class.php

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.