2

Here is my code.

defined( 'ABSPATH' ) || exit;

namespace JSR;

class myClass{
...
}

This is giving below error

Global code should be enclosed in global namespace declaration

Any idea how to fix it?

4
  • namespace JSR; is the first line in code Commented Feb 13, 2017 at 7:02
  • It is as in the code. Commented Feb 13, 2017 at 7:04
  • @MASIDDIQUI or do you mean I should place namespace at the top of everything? Commented Feb 13, 2017 at 7:06
  • 1
    yes name space should be the first line Commented Feb 13, 2017 at 7:08

1 Answer 1

2

Just do this...

namespace JSR;

defined( 'ABSPATH' ) || exit;

class myClass{
...
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.