Tags
PHP
Asked 3 years ago
20 May 2021
Views 521
samir

samir posted

die() function in PHP

what is use of die() function in PHP ?
how to use die() function in PHP ?

i tried following code :

die(123);

it did nothing .
sqltreat

sqltreat
answered Nov 30 '-1 00:00

die() function do following job:
1. die() function stop the execution of the script
2. die() function will print the string which passed as an argument in the die() function


die("I am in die function");
echo "i am after die function";

above code will print "i am in die function" but it will not run after code of die() function so it will not print or next statement


die(1);


if you pass the number as an argument to the die() function, it will only stop the script execution to that point but not print anything but it take number exit status


Post Answer