Question

In Python I normally do print type(someObject) to view the type of a variable value. I now need to do a similar thing in php in which I want to print the type to the syslog. So I do this:

syslog(LOG_ERR, gettype($myObject));

The result is

Apr 30 13:54:09 php0 php: object

I presume the object is an instance of a my class called ReceivedMail, but since it just prints out object I have no way of knowing this.

Is there a way to print the type of an object (or the class it was instantiated from) to the syslog in php? All tips are welcome!

Était-ce utile?

La solution

Assuming this is for debugging or logging, you can use get_class.

If you need to verify an object's class you will typically use instanceof because of polymorphism.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top