Jump to content
Tyssen

Class 'ProcessWire\SimpleXMLElement' error after adding namespace

Recommended Posts

I've added a function to my _init file but found it wasn't working until I added a namespace to _init and any other file calling a function from _init.

But on one template I've got new SimpleXMLElement which is causing the 'class not found error' which appears to be due to the namespacing.

What do I need to do to solve that?

Share this post


Link to post
Share on other sites
24 minutes ago, Tyssen said:

What do I need to do to solve that?

Prefix the name with \ to specify the global space:

$foo = new \SimpleXMLElement($data);

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Wow, that simple. Thanks! 🙂

  • Like 1

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...