Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Aimgy's avatar
Level 1

Use LogicException from PHP

Hello,

I want to use a LogicException class from PHP so I set in my code:

"use LogicException;

if (Atest) { Some Code } else { throw new LogicException("blablabla"); }"

But I have always this error:

"FatalThrowableError in Character.php line 243: Call to undefined function App\LogicException()"

Obviously, there is no LogicException class in my App Folder because I want to use the default PHP class.

Can someone help me? thank you in advance.

0 likes
2 replies
ohffs's avatar
ohffs
Best Answer
Level 50

If you do throw new \LogicException, does that work?

1 like
Aimgy's avatar
Level 1

Yes it work :)

Thank you!

Please or to participate in this conversation.