문제

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!

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top