I got to know this while learning PHP and I don't exactly know what is this used for, and this is while connecting to database
Asked
Active
Viewed 1,086 times
-3
-
https://secure.php.net/manual/en/function.die.php – brombeer Feb 22 '19 at 11:46
1 Answers
0
PHP die
function will print the string inside it and will stop the execution of further code. Generally in shared code case, Developer check whether s/he is able to connect with database or not. If developer is able to connect with database, it will allow access of website else it will just show an error (which appears by $conn->connect_error
method) and will stop code.
So basically if you PHP script is not able to connect with database, then it will show error message that why it is not able to connect and will stop further process. Hope it helps you to clarify this syntax.

Rohit Mittal
- 2,064
- 2
- 8
- 18