DEV Community

Abdul Bari Buriro
Abdul Bari Buriro

Posted on

how die() helps you in debugging (PHP)

HOW die() HELPED ME IN DEBUGGING

As a beginner PHP developer I used to struggle a lot in debugging specially when projects are large and with legacy code, then one of my senior advised to use die(), at first I was surprised as we use die() for stopping script completely not something that comes under debugging rule, as per my knowledge.

BUT....

It turned out to be life saving, it lets you know exactly where you are on the code, and what values you want to check (EXTREMELY HELPFUL IN BACKEND) even you can die the query in the die() (example: die("SELECT * FROM USERS WHERE id = $id")). I got better at it; however this should be not used in live code to avoid any server related issues.

That’s all for now.

Signing off....

  • Buriro

Top comments (0)