froot Posted August 20, 2022 Posted August 20, 2022 I have to use the php standard class stdClass for my function to work. But that doesn't work in the Processwire namespace. What's the equivalent in Processwire? I think it's the best bet to find an equivalent API instead of going in and out of different namespaces.
Jan Romero Posted August 20, 2022 Posted August 20, 2022 Put a backslash in front if you want to use PHP classes, or am I missing something? It’s near impossible to answer your question without knowing why you want to use stdClass. Could well be that ProcessWire has something suitable for your use case, but what is your use case? 1
froot Posted August 20, 2022 Author Posted August 20, 2022 you mean like \stdClass() that's it? It's probably a very basic question so you're probably not missing anything.
Jan Romero Posted August 20, 2022 Posted August 20, 2022 Yes, in a file with namespace ProcessWire that will let you use it: $foo = new \stdClass(); You can also put “use \stdClass” at the top if you need it a lot. The same goes for all the other stuff outside PW’s namespace. Often you’ll need \DateTime or \IntlDateFormatter for example. Edit: the technical term is “The Global Space”: https://www.php.net/manual/en/language.namespaces.global.php 3
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