froot Posted April 28, 2021 Share Posted April 28, 2021 how can I return the type of an object? if it's a page array return PageArray. If it's a single page return PageObject etc. In plain php, this is done by gettype. When I use that here, everything is object, so it's not useful… Link to comment Share on other sites More sharing options...
MoritzLost Posted April 28, 2021 Share Posted April 28, 2021 You're confusing variable type and object classes. gettype() returns the type of a variable, i.e. string, int, object etc. If you want to know the class, use get_class(). Note that this will return the fully qualified classname, i.e. ProcessWire\PageArray. If you want to get the classname without the namespace, you can also use Wire::className, which is a method available on all classes extending the Wire class (so pretty much all ProcessWire classes). This one gives you only the classname with the namespace by default: $somePageArray->className(); // PageArray 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now